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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:32:10+00:00 2026-05-22T20:32:10+00:00

i have gone through a number of tutorials to get an idea as to

  • 0

i have gone through a number of tutorials to get an idea as to how can we parse JSON object. the structure of ma JSON object response from web service is like this

{"posts":[

{"gpoint":{"latitude":"18.966364","longitude":"72.811317"}},

{"gpoint":{"latitude":"19.07023","longitude":"72.82917"}},

{"gpoint":{"latitude":"19.094889","longitude":"72.840157"}},

{"gpoint":{"latitude":"19.056601","longitude":"72.901955"}}]

}

and this is my code:

       HttpResponse response= client.execute(post);

       content = response.getEntity().getContent();

       String result = stringConversion(content);   


       jObject = new JSONObject(result);

       JSONArray gpoint = jObject.getJSONArray("posts");

       for (int i = 0; i<gpoint.length();i++)
       {

            double geoLat=gpoint.getJSONObject(i).optDouble("latitude");
            double geoLong=gpoint.getJSONObject(i).optDouble("longitude");

       //   double geoLat = gPointObject.getDouble("latitude");
       //   double geoLong = gPointObject.getDouble("longitude");      
            Log.i(Tag," "+ geoLat);
            Log.i(Tag," "+ geoLong);
       }

}   


catch(JSONException e){
    Log.e("log_tag", "Error parsing data "+e.toString());
}

I am not able to parse this response, whenever I am parsing it, it does not give any parse exception but the value for latitude and longitude is NaN

Kindly tell me, where am I going wrong? Thanks in advance.

  • 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-22T20:32:10+00:00Added an answer on May 22, 2026 at 8:32 pm

    Try this:

    JSONObject gp;
    for (int i = 0; i<gpoint.length();i++)
            {
    gp = gpoint.getJSONObject(i);
    double geoLat = gp.getJSONObject("gpoint").optDouble("latitude");
    double geoLong = gp.getJSONObject("gpoint").optDouble("latitude");
    
            //  double geoLat = gPointObject.getDouble("latitude");
            //  double geoLong = gPointObject.getDouble("longitude");      
                Log.i(Tag," "+ geoLat);
                Log.i(Tag," "+ geoLong);
           }
    

    You’re missing one nesting layer.

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

Sidebar

Related Questions

Have gone through hibernate api specification on FlushMode but didn't get the exact difference.
I have gone through N number of solutions for creating a dynamic dropdown in
I have gone through number of post regarding tx with spring and AspectJ. Below
I have gone through Google and Stack Overflow search, but nowhere I was able
I have gone through this to change the color of my title bar. I'm
I have gone through this page... http://www.php.net/manual/en/function.hash.php MD5 is 32 characters long while sha1
I have gone through a couple of similar questions but could reach a definite
I have gone through the fadein/fadeout tutorial that is on this page: For the
I have gone through many posts on SO regarding this issue: Tried everything in
I have gone through different questions/articles on Message Brokers and ESBs(Even on stackoverflow). Still

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.