嵌套HashMap的参数发送请求凌空 [英] sending volley request with nested hashmap parameters

查看:151
本文介绍了嵌套HashMap的参数发送请求凌空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Android的凌空抽射框架发送的JSONObject请求我server.get请求工作fine.now我想发送带有请求参数POST请求是嵌套的HashMap<字符串,对象>。我重写getparams方法,但它希望我送的HashMap<字符串,字符串>。

i am using android volley framework for sending jsonobject request to my server.get request is working fine.now i would like to send a post request with request parameters which is nested hashmap< string,object >.i override the getparams method but it expects me to send hashmap< string,string >.

有任何的方式来传递的HashMap作为请求参数?

there is any way to pass hashmap as request parameter?

我按照这个链接在这里输入链接的描述

推荐答案

试试下面覆盖的方法,它是从源头code:

try override below method, it is from source code:

/**
 * Returns the raw POST or PUT body to be sent.
 *
 * @throws AuthFailureError in the event of auth failure
 */
public byte[] getBody() throws AuthFailureError {
    Map<String, String> params = getParams();
    if (params != null && params.size() > 0) {
        return encodeParameters(params, getParamsEncoding());
    }
    return null;
}

返回原始POST或PUT体发送。

所以重写 getBody()您的参数。

这篇关于嵌套HashMap的参数发送请求凌空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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