问题
I would like to create JsonArrayRequest using Volley POST but I need to put JSON parameters to the request which look like this
{"filter":{"minLat":15.0,"minLng":14.0,"maxLng":12.0,"maxLat":16.2,"validOnly":true,"groupDistance":1,"vehicleType":1,"serviceTypes":[1,2]},"username":"email@email.cz","securityToken":"securityToken"}
And I'm not able to figure it out. Is there somebody who can help me? Thank you
回答1:
If not too late and your issue hasn't been solved. IMO, you can init your JSONOjbect like the following:
JSONObject jsonObject = new JSONObject();
JSONObject jsonObject2;
try {
jsonObject.put("minLat", 15.0);
jsonObject.put("minLng", 140);
...
jsonObject2 = new JSONObject().put("filter", jsonObject);
} catch (JSONException e) {
e.printStackTrace();
}
Then, use jsonObject2
in your request. Hope this helps!
来源:https://stackoverflow.com/questions/26177697/volley-send-jsonarrayrequest-via-post-with-jsonobject-data