如何以这种格式发送json请求

Sac*_*wha 0 android

我想以这种格式发送json请求

"coordinates":{"0":{"received_at":1471529314,"lat":28.6888798,"long":77.3247225}}
Run Code Online (Sandbox Code Playgroud)

但我能够以这种格式发送请求

{"coordinates":{"0":{"received_at":1471529314,"lat":28.6888798,"long":77.3247225}}}
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码

            jsonObject.put("received_at", now);
            jsonObject.put("lat", latitude);
            jsonObject.put("long", longitude);
            JSONObject json = new JSONObject();
            json.put("0",jsonObject);
            jsonObject1 = new JSONObject();
            jsonObject1.put("coordinates",json);
            Log.e("JSON",jsonObject1.toString());
Run Code Online (Sandbox Code Playgroud)

0xD*_*0DE 5

您共享的第一个请求不是有效的JSON.JSON字符串必须始终以a开头{以指示JSONObject或使用a [来指示JSONArray.
如果你坚持使用第一种格式,我认为你必须自己构建那个字符串