我正在尝试使用 volley 库制作标准的 JsonObjectRequest。除了请求的响应外,一切都运行良好。
这是我执行请求的方式:
JSONObject jsonObject = new JSONObject();
jsonObject.put("geoLong", location.getLongitude());
jsonObject.put("geoLat", location.getLatitude());
JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.POST, url,
jsonObject.toString(), createResponseListener(), createErrorListener());
jsonRequest.setRetryPolicy(new DefaultRetryPolicy(15000, 2, 1));
requestQueue.add(jsonRequest);
我期望以下 json 响应:
{
"total": 79,
"results": [
{
"id": "123",
"title": "test",
"distance": 3873.7552258171,
"address": {
"street": "Street",
"zip": "12345",
"city": "city",
"country": "country",
},
"geo": {
"longitude": x,
"latitude": y
}
},
...
...
]}
但从我的 Volley Request 我得到这样的东西:
{
"nameValuePairs": {
"total": 79,
"results": {
"values": [{
"nameValuePairs": {
"id": 123,
"title": "test",
"distance": 3873.7552258171,
"address": {
"nameValuePairs": {
"street": "street",
"zip": "zip",
"city": "city",
"country": "country"
}
},
"geo": {
"nameValuePairs": {
"longitude": x,
"latitude": y
}
}
},
...
...
}]}}
有谁知道为什么响应的格式是这样的,我怎样才能把它改成我期望的?