Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with parsing through JSON object: here is the json object, I need to get the value of lat and long and store it into

Help with parsing through JSON object:

image text in transcribed

here is the json object, I need to get the value of lat and long and store it into

String latLong = lat + "," +long;

here is my code, what am i doing wrong?:

private static String parseGeocodeResponse(String response)

{

// TODO 4: Convert response string to JSON & dive down into JSON response to get lat/long

//convert string to JSONObject

JSONObject objResponse = new JSONObject(response);

//Get results array

JSONArray arrResults = objResponse.getJSONArray("results");

for (int r = 0; r

JSONObject objResult = arrResults.getJSONObject(r);

//looks through json object to get name and vicinity/address

//get name and address

String addressLat = objResult.getString("lat");

String addressLong = objResult.getString("long");

String latLong = addressLat + "," + addressLong;

}

return latLong;

}

- results: + address_components: [ formatted address: "1600 Pennsylvania Ave NW, Washington, DC 20500, USA", - geometry: 1 + bounds: ...), location: \ lat: 38.8976633, lng:77.0365739 location type: "ROOFTOP", + viewport: [... 1, place_id: "ChIJGVtI4by3t4kRr51d Qm_x58", types: [.] 1, status: "OK" - results: + address_components: [ formatted address: "1600 Pennsylvania Ave NW, Washington, DC 20500, USA", - geometry: 1 + bounds: ...), location: \ lat: 38.8976633, lng:77.0365739 location type: "ROOFTOP", + viewport: [... 1, place_id: "ChIJGVtI4by3t4kRr51d Qm_x58", types: [.] 1, status: "OK

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago