Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7418007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:48:20+00:00 2026-05-29T07:48:20+00:00

i have the following JSON response from google maps. I’ve given two postcodes as

  • 0

i have the following JSON response from google maps. I’ve given two postcodes as the start and destination. It describes the route in the response so that part is working. I’d like to get the longitude and latitude from the response so that i can load the respective map. The problem i’m having is that “northeast” attribute cannot be found, any ideas?

02-05 18:50:03.668: E/*********HelloviewActivity(10381): response code OK 
02-05 18:50:03.673: E/*********HelloviewActivity(10381): {
02-05 18:50:03.673: E/*********HelloviewActivity(10381):    "routes" : [
02-05 18:50:03.673: E/*********HelloviewActivity(10381):       {
02-05 18:50:03.673: E/*********HelloviewActivity(10381):          "bounds" : {
02-05 18:50:03.673: E/*********HelloviewActivity(10381):             "northeast" : {
02-05 18:50:03.678: E/*********HelloviewActivity(10381):                "lat" : 53.654430,
02-05 18:50:03.678: E/*********HelloviewActivity(10381):                "lng" : -1.778250
02-05 18:50:03.678: E/*********HelloviewActivity(10381):             },
02-05 18:50:03.678: E/*********HelloviewActivity(10381):             "southwest" : {
02-05 18:50:03.683: E/*********HelloviewActivity(10381):                "lat" : 53.62041000000001,
02-05 18:50:03.683: E/*********HelloviewActivity(10381):                "lng" : -1.831710
02-05 18:50:03.683: E/*********HelloviewActivity(10381):             }
02-05 18:50:03.683: E/*********HelloviewActivity(10381):          },

.

String jsonOutput = response.toString();
      //  Log.e(TAG,"jsonOutput = " + jsonOutput);

        JSONObject results = null;
        try {

            results = new JSONObject(jsonOutput);


            routes = results.getJSONArray("routes");


            bounds = routes.getJSONObject(0);

            northeast = bounds.getJSONObject("northeast");


             lat = Double.parseDouble((String) northeast.get("lat"));


             lon = Double.parseDouble((String) northeast.get("lng"));

        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        Log.e(TAG, "lon/lat = "+lon +" "+lat);

.

02-05 18:50:04.668: W/System.err(10381): org.json.JSONException: JSONObject["northeast"] not found.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:48:21+00:00Added an answer on May 29, 2026 at 7:48 am

    routes is an array of (anonymous) objects that contain the bounds object.

    anonObject = routes.getJSONObject(0);
    bounds = anonObject.getJSONObject("bounds");
    

    Edit: Also – once you get your bounds object; lat and lng aren’t Strings – they’re already Doubles – you don’t do any conversion:

    lat = bounds.getDouble("lat");
    lon = bounds.getDouble("lng");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following string from a REST JSON response: [ { uid:10512213, name:Bob
I have the following scenario: I am parsing a JSON Response from a server
Say I have the following JSON string returned from server: { response:{ imageInstances:{ one:{
I have the following JSON object: { response: { status: 200 }, messages: [
I have following array return from server side: [json] => Array ( [0] =>
I have the following response in JSON format, but, can't seem to figure out
I have written down the following code: var url = http://maps.googleapis.com/maps/api/geocode/json?latlng=+position.coords.latitude+,+position.coords.longitude+&sensor=false&callback=parseMe; console.log('URL is --
I have to following response from a server: page:{result:ok,id_photo:36782710} .And I'm trying to obtain
I have written following code to get JSON result from webservice. function SaveUploadedDataInDB(fileName) {
I have the following JSON structure: [{ id:10, class: child-of-9 }, { id: 11,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.