How do I access these JSONObjects?
Asked
Active
Viewed 62 times
0
-
please edit your question to include the full JSON – meda Oct 18 '14 at 13:36
3 Answers
1
37.422258 is not in quotes, so it's interpreted as a double not a string. Try calling getDouble.
Luke Usherwood
- 2,949
- 1
- 26
- 33
-
Ah getDouble makes more sense. But I am still receiving that "location" was not found. – milkncereal Oct 18 '14 at 13:44
0
you can get a answer from this post.. looks like a duplicate question:
How to convert String to JSONObject in Java
hope it will help you to get some idea....
Community
- 1
- 1
Nomesh DeSilva
- 1,635
- 4
- 24
- 43
0
I asked you to show your full JSON because the picture is blurry and it is always good to show the text but here is how you parse the JSON
JSONObject dataObj = new JSONObject(jsonString);
JSONArray results = dataObj.getJSONArray("results");
JSONObject geometry = results.getJSONObject(0).getJSONObject("geometry");
JSONObject location = geometry.getJSONObject("location");
lat = String.valueOf(location.getDouble("lat"));
lng = String.valueOf(location.getDouble("lng"));
meda
- 44,540
- 14
- 88
- 122