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 8197397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:43:57+00:00 2026-06-07T05:43:57+00:00

I am trying to read results of a JSON request into java, yet The

  • 0

I am trying to read results of a JSON request into java, yet
The partial output of my JSON request looks like this :

"route_summary": {
        "total_distance": 740,
        "total_time": 86,
        "start_point": "Marienstraße",
        "end_point": "Feldbergstraße"
    }

I would like to use the standard json library to extract the values in total_distance.
However I only seem to be able to get the ‘route_summary’ by doing this :

JSONObject json = null;
json = readJsonFromUrl(request);
json.get("route_summary");

Where

public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
        InputStream is = new URL(url).openStream();
        try {
            BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
            String jsonText = readAll(rd);
            JSONObject json = new JSONObject(jsonText);
            return json;
        } finally {
            is.close();
        }
    }

What I want is get ‘into’ route_summary, any clue / tip would be great !

  • 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-06-07T05:43:58+00:00Added an answer on June 7, 2026 at 5:43 am

    You need to get route_summary, as you already did, and from that object you need to get the total_distance. This will give you back the route_summary.total_distance.

    Code sample:

        JSONObject object = new JSONObject(s);
        int totalDistance = object.getJSONObject("route_summary").getInt("total_distance");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new at JSON, I'm trying to read one parameter of this file
I'm trying to read a remote binary file (say, image) from internet like this:
I am trying to read a JSON stream of data like so- string Username
I'm trying to use gson to convert this returned JSON into some kind of
Trying to read in some information from the google maps api into my application
I am trying to read JSON objects using the QScriptValue class in Qt and
I'm trying to get Jquery to read a json file, But unfortunately I can
This may be more of a scoping question. I'm trying to set a JSON
Is there a way to output the json-string read by my store in sencha
I am trying to read a JSON string: { also_known_as: [ Сильвестр Сталлоне ],

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.