我有这样的JSON。
[
{"latitude":40.91769,"longtitude":29.18127},
{"latitude":40.91863,"longtitude":29.18149},
{"latitude":40.91868,"longtitude":29.18153},
///-------///
{"latitude":40.91423,"longtitude":29.18741},
{"latitude":40.91471,"longtitude":29.18587}
]
但我没有像树一样的结构。它更像是一个阵列。我如何逐个解析它的纬度和经度?
答案 0 :(得分:0)
public void parseJson(String json) {
try {
JSONArray root = new JSONArray(json);
for (int i = 0; i < root.length(); i++) {
JSONObject att = (JSONObject) root.getJSONObject(i);
String lat = att.getString("latitude");
String log = att.getString("longtitude");
}
} catch (JSONException e) {
e.printStackTrace();
}
}