-5

I have a JSON like this.

[
  {"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}
]

But I don't have a structure like an tree. It's more like an array. How can i parse it latitude and longitude one by one?

Litisqe Kumar
  • 2,442
  • 4
  • 24
  • 39
user3717742
  • 93
  • 1
  • 7

1 Answers1

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();
      }
    }
Iamat8
  • 3,812
  • 8
  • 23
  • 33