How can I iterate JSONObject to get individual items

前端 未结 2 867
南方客
南方客 2020-11-30 03:19

This is my below code from which I need to parse the JSONObject to get individual items. This is the first time I am working with JSON. So not sure how to parse

2条回答
  •  无人及你
    2020-11-30 04:10

    How about this?

    JSONObject jsonObject = new JSONObject           (YOUR_JSON_STRING);
    JSONObject ipinfo     = jsonObject.getJSONObject ("ipinfo");
    String     ip_address = ipinfo.getString         ("ip_address");
    JSONObject location   = ipinfo.getJSONObject     ("Location");
    String     latitude   = location.getString       ("latitude");
    System.out.println (latitude);
    

    This sample code using "org.json.JSONObject"

提交回复
热议问题