凌空通过POST发送JsonArrayRequest用的JSONObject数据 [英] Volley send JsonArrayRequest via POST with JsonObject data

查看:165
本文介绍了凌空通过POST发送JsonArrayRequest用的JSONObject数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用凌空POST创建JsonArrayRequest,但我需要把JSON参数,它看起来像这样的要求

<$p$p><$c$c>{\"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\"}

和我无法弄清楚。有没有人谁可以帮我?
谢谢


解决方案

如果还不算晚,你的问题一直没有得到解决。海事组织,你可以初始化你JSONOjbect这样的:

 的JSONObject的JSONObject =新的JSONObject();
        的JSONObject jsonObject2;
        尝试{
            jsonObject.put(minLat,15.0);
            jsonObject.put(minLng,140);
            ...            jsonObject2 =新的JSONObject()把(过滤,JSONObject的)。
        }赶上(JSONException E){
            e.printStackTrace();
        }

然后,使用 jsonObject2 在您的请求。希望这有助于!

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

解决方案

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!

这篇关于凌空通过POST发送JsonArrayRequest用的JSONObject数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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