sending volley request with nested hashmap paramet

2019-09-11 03:25发布

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 >.

there is any way to pass hashmap as request parameter?

i have followed this link enter link description here

2条回答
家丑人穷心不美
2楼-- · 2019-09-11 03:50

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;
}

Returns the raw POST or PUT body to be sent.

so override the getBody() with your parameter.

查看更多
放荡不羁爱自由
3楼-- · 2019-09-11 04:10

You can use the getParamsEncoding in override method getBody().

Here, this link will help you.

查看更多
登录 后发表回答