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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:46:02+00:00 2026-06-15T06:46:02+00:00

json object from REST service { destination_addresses : [ Chicago, IL, USA ], origin_addresses

  • 0

json object from REST service

{
   "destination_addresses" : [ "Chicago, IL, USA" ],
   "origin_addresses" : [ "Syracuse, NY, USA" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "1,090 km",
                  "value" : 1090383
               },
               "duration" : {
                  "text" : "10 hours 21 mins",
                  "value" : 37242
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

Using code from JacksonInFiveMinutes

ObjectMapper mapper = new ObjectMapper();
Map userData = mapper.readValue(webResource.queryParams(queryParams).get(String.class);, Map.class);

Where:

webResource.queryParams(queryParams).get(String.class);

returns the json from REST service

From Json I would like the 2 address properties as well as the distance property as well as the 2 status.

My hack attempt:

ObjectMapper mapper = new ObjectMapper();
JsonNode jnode = mapper.readValue(s, JsonNode.class);
jnode.findValue("distance").findValue("value") // 

this gets me the value I am looking for.

Not sure if this is good way to go about

  • 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-15T06:46:03+00:00Added an answer on June 15, 2026 at 6:46 am

    It looks OK to me, except that it would be safer to not chain those two findValue() calls together, as you could get a NPE if the JSON string doesn’t contain the first one. From the JsonNode javadoc:

    public abstract JsonNode findValue(String fieldName)

    Method for finding a JSON Object field with specified name in this
    node or its child nodes, and returning value it has. If no matching
    field is found in this node or its descendants, returns null.

    So I’d check the first findValue() result and if its not null, then perform the second findValue() (with logging to notify you if this happens).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Restful Service (from Server) @GET @Produces(application/json) @Consumes(application/json) @Path(/getStatus/) // server:8080/server/rest/admin/status/whatSoEver public void getStatus( @Context
I'm sending a JSON collection from Javascript through a REST web service to be
I want to create a JSON object from my MySQL results with PHP so
I am trying to return a JSON object from an aspx page using Jayrock.JSON.
I want to send a JSON object from the client to an action on
I'm currently trying to post a JSON object from my view to my controller
I'm trying to get the JSON object from a JSON outputted string from a
I am trying to receive a json object back from php after sending data
What's the ideal way to pass a large JSON data object from Javascript through
I am using Node.js (with Express.js) to pass a JSON data object from the

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.