2017-08-13 20 views

答えて

0
あなたはこのように試すことができ

try { 
    JSONObject jsonObject = new JSONObject(); 

    jsonObject.put("latitude", location.getLatitude()); 
    jsonObject.put("longitude", location.getLongitude()); 
    jsonObject.put("request_id", "[your requireId]"); 

    JSONArray routeArray = new JSONArray(); 

    //instead df 2 give your array side 
    for (int i = 0; i < 2; i++) { 
     JSONObject routeJsonObject = new JSONObject(); 

     routeJsonObject.put("latitude", location.getLatitude()); 
     routeJsonObject.put("longitude", location.getLongitude()); 

     routeArray.put(routeJsonObject); 
    } 

    jsonObject.put("routes", routeArray); 

    Log.d("", "onCreate: " + jsonObject.toString()); 

    new JsonObjectRequest(Request.Method.POST, url, jsonObject, new Response.Listener<JSONObject>() { ... }); 
} catch (JSONException e) { 
    e.printStackTrace(); 
} 
+0

感謝の弟 –

関連する問題