How do I access a JSONObject subfield?

前端 未结 4 2078
自闭症患者
自闭症患者 2021-02-13 23:03

I feel dumb but I\'ve been looking around for this for a while. I\'m working with the google geocoder API and I need a bit of help with the json responses. Here is a JSONObje

4条回答
  •  一整个雨季
    2021-02-13 23:46

    I believe you'd need to use jsonObjectVariable.getJSONObject("location") which in turn returns another JSONObject.

    You can then invoke getDouble("lng") or getDouble("lat") on that object.

    E.g.

    double lat = jsonObjectVariable.getJSONObject("location").getDouble("lat");
    

提交回复
热议问题