Volley Post请求,在Json数组请求中发送Json对象 [英] Volley Post request ,Send Json object in Json array request

查看:208
本文介绍了Volley Post请求,在Json数组请求中发送Json对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单地说,我想使用Volley Post Request将此{"Id":7,"Name":"MyName"}数据发送到服务器.

To say in simple words i want to send this {"Id":7,"Name":"MyName"} data To server using Volley Post Request.

它有1个整数和1个字符串,我得到的响应是Jsonarray

It has 1 integer and 1 String and response i get is Jsonarray

我尝试了以下方法,但没有用

I tried Following ways but none are working

  • 因为它是json数组请求,所以我无法在参数中发送数据,因为第三个参数仅使用JsonArray,并且我必须发送JsonObject,因此将其保留为空

  • as it is json array request i cannot send data in argument as 3rd argument only takes JsonArray and i have to send JsonObject so kept it as null

new JsonArrayRequest(Method,Url,JsonArray,ResponseListener,ErrorListner)

我不能将其放在HashMap中,因为该值的1是整数,并且仅接受字符串

I cannot put it in HashMap as 1 of the value is integer, and it only accepts string

getparams()方法

getparams() method

@Override
protected Map<String, String> getParams() throws AuthFailureError {
    Map<String,String> params=new HashMap<>();
    params.put("Id",7); //            <====== This is Invalid
    params.put("Name","MyName");
    return params;
}

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆