Volley send JsonArrayRequest via POST with JsonObject data

落花浮王杯 提交于 2020-01-16 22:22:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!