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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:39:57+00:00 2026-06-18T09:39:57+00:00

JSON response value looks like this types : [ sublocality, political ] . How

  • 0

JSON response value looks like this "types" : [ "sublocality", "political" ]. How to get the first value of the types or how to get the word sublocality?

  • 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-18T09:39:58+00:00Added an answer on June 18, 2026 at 9:39 am
    String string = yourjson;
    
    JSONObject o = new JSONObject(yourjson);
    JSONArray a = o.getJSONArray("types");
    for (int i = 0; i < a.length(); i++) {
        Log.d("Type", a.getString(i));
    }
    

    This would be correct if you were parsing only the line you provided above. Note that to access types from GoogleMaps geocode you should get an array of results, than address_components, then you can access object components.getJSONObject(index).

    This is a simple implementation that parses only formatted_address – what I needed in my project.

    private void parseJson(List<Address> address, int maxResults, byte[] data)
    {
        try {
            String json = new String(data, "UTF-8");
            JSONObject o = new JSONObject(json);
            String status = o.getString("status");
            if (status.equals(STATUS_OK)) {
    
                JSONArray a = o.getJSONArray("results");
    
                for (int i = 0; i < maxResults && i < a.length(); i++) {
                    Address current = new Address(Locale.getDefault());
                    JSONObject item = a.getJSONObject(i);
    
                    current.setFeatureName(item.getString("formatted_address"));
                    JSONObject location = item.getJSONObject("geometry")
                            .getJSONObject("location");
                    current.setLatitude(location.getDouble("lat"));
                    current.setLongitude(location.getDouble("lng"));
    
                    address.add(current);
                }
    
            }
        catch (Throwable e) {
            e.printStackTrace();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get a json response from the server that looks something like this: {
My Spring Controller class looks like this @SuppressWarnings(rawtypes) @RequestMapping(value = /cityGridView, method = RequestMethod.GET)
My JSON response looks like this : {sample:[{id:2,name:branch name},{id:3,name:branch name 2}]} My function looks
I have a json that looks like this {abcd: { id: 1234, response: authenticated,
I am getting json response from this google api service to get reverse geo
I am getting json response like this {item_id:1,item_title:Item 1}{item_id:2,item_title:Item 2} how would I parse
my jquery looks like this: $('#id_start_date_list').change( function get_time() { var value = $(this).attr('value'); alert(value);
I'm struggling in setting a function's return value to the json response of its
im getting response in json, but this wont parse the json response. what m
I have a json response like: { total: 2, success: true, rows: [ {a1_id:7847TK10,

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.