我想解析一個列表中的緯度和另一個列表中的經度。 任何想法如何在android.i中實現這一點,我正在谷歌地圖上繪製路線,所以我將需要經緯度和緯度。如何解析jsonobject到兩個不同的列表
{
"userData": [
{
"Latitude": "28.597782",
"Longitude": "77.298256",
"IotName": "Bus7821",
"createdAt": "2016-06-10T09:23:07.244Z",
"updatedAt": "2016-06-10T09:23:07.244Z",
"id": "575a86fbaf4d65a333c1a1b6"
},
{
"Latitude": "28.598390",
"Longitude": "77.297952",
"IotName": "Bus7821",
"createdAt": "2016-06-10T09:24:04.265Z",
"updatedAt": "2016-06-10T09:24:04.265Z",
"id": "575a8734af4d65a333c1a1b7"
},
{
"Latitude": "28.598362",
"Longitude": "77.297866",
"IotName": "Bus7821",
"createdAt": "2016-06-10T09:25:03.522Z",
"updatedAt": "2016-06-10T09:25:03.522Z",
"id": "575a876faf4d65a333c1a1b8"
}
]
}
我的代碼片段
JSONObject parentObject = new JSONObject(buffer.toString());
routeMap = parentObject.getJSONArray("userData");
for (int i=0 ; i<routeMap.length();i++)
{
JSONObject routes = routeMap.getJSONObject(i);
// routeLatitude = routes.get("Latitude");
}
使用'routes.getString(「Latitude」);''和'routes.getString(「Longitude」);'爲緯度和經度resp。 –
你面臨什麼問題? – Mohit