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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:03:48+00:00 2026-06-04T07:03:48+00:00

It was going good until I needed to parse the type of the place,

  • 0

It was going good until I needed to parse the type of the place, the file is organized like this:

        "geometry" : {
        "location" : {
           "lat" : 45.7849210,
           "lng" : 11.8724490
        },
        "viewport" : {
           "northeast" : {
              "lat" : 45.81619110,
              "lng" : 11.89575470
           },
           "southwest" : {
              "lat" : 45.75432980,
              "lng" : 11.84532520
           }
        }
     },
     "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
     "id" : "a454072e2ba71d4e2331e39099261f086cd11d1e",
     "name" : "Fonte",
     "reference" : "CnRtAAAAUaGSsbXRv05lApqXueEKjOAjtkpEDz07ioe3vPS9HqpOIJSTTQWYObc6o6GfEq-pzVUtKT03oRWNx6ld-rUfdat47e8W3NbSsLY1NldO9iQEUjQOM9kIIOix8xLAvqh5YHUNTAela4Mo8HGSJPPBhhIQ9j4Uy_WrQtFO7qxirA0UHRoUsmY0ngstG5BBiHQNLkLgxTpsDEY",
     "types" : [ "locality", "political" ],
     "vicinity" : "Fonte"
  },

As it is possible to notice that types is an string array I tried this approach:

  JSONArray results = o.getJSONArray("results");
  JSONObject tempObject = results.getJSONObject(0);
  JSONArray typee = tempObject.getJSONArray("types");
  String a = typee.getJSONObject(0).toString();

but it doesn’t work.Any help will be appreciated.The whole JSON can be seen here: https://maps.googleapis.com/maps/api/place/search/json?location=45.7909,11.8700&radius=500&key=AIzaSyC9Ob9_u-2mxCHeItDHytDLmZP-P1QCejw&sensor=true.

  • 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-04T07:03:49+00:00Added an answer on June 4, 2026 at 7:03 am
    JSONArray typee = tempObject.getJSONArray("types");
    String a = typee.getString(0);
    String b = typee.getString(1);
    

    The above will return locality to variable a and political to variable b. Use typee.length() to find out how many elements are in the JSONArray if it’s possible that types might have a variable number of elements.

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

Sidebar

Related Questions

Without going into whether this is a good or bad idea: Is it possible
Good-morning one and all! This is going to end up being one of those
I am have started learning Rails, it was going good until now. I am
I've been going through some good (seeming) resources for Rails tutorials, and will dutifully
I'm just getting started on a new MVC project, and like a good boy
I do admit this question is going to be a bit vague, but I
I have a categories table in MySql something like this: categoryId | categoryTitle |
I'm doing a non-automated git bisect via command line. All is going well until
Good morning, all. This is my first question on stackoverflow, so hopefully this isn't
perl -MCPAN -e'install File::Find::Rule' CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Database was

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.