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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:40:38+00:00 2026-05-27T00:40:38+00:00

How to parse this Json using Gson and display the Placetype _Name and Place

  • 0

How to parse this Json using Gson and display the Placetype _Name and Place details?

I have this json and need help for parsing and and displaying the Placetype _Name and Place details.

{
  "PlacesList": {
"PlaceType": [
  {
    "-Name": "Airport",
    "Places": {
      "Place": [
        {
          "name": "Juhu Aerodrome",
          "latitude": "19.09778",
          "longitude": "72.83083",
          "description": "Juhu Aerodrome is an airport that serves the metropolitan" 
        },
        {
          "name": "Chhatrapati Shivaji International Airport",
          "latitude": "19.09353",
          "longitude": "72.85489",
          "description": "Chhatrapati Shivaji International Airport  "
        }
      ]
    }
  },
  {
    "-Name": "Mall",
    "Places": {
      "Place": [
        {
          "name": "Infinity",
          "latitude": "19.14030",
          "longitude": "72.83180",
          "description": "This Mall is one of the best places for all types of brand"
        },
        {
          "name": "Heera Panna",
          "latitude": "18.98283",
          "longitude": "72.80897",
          "description": "The Heera Panna Shopping Center is one of the most popular"
        }
      ]
    }
  }
]
  }
} 
  • 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-27T00:40:39+00:00Added an answer on May 27, 2026 at 12:40 am

    An easy solution to handle the JSON element name that starts with “-“, which is a character that cannot be used to start a Java identifier name, is to make use of the @SerializedName annotation.

    import java.io.FileReader;
    import java.util.List;
    
    import com.google.gson.Gson;
    import com.google.gson.annotations.SerializedName;
    
    public class GsonFoo
    {
      public static void main(String[] args) throws Exception
      {
        Response response = new Gson().fromJson(new FileReader("input.json"), Response.class);
        System.out.println(response.PlacesList.PlaceType.get(0).Name);
        System.out.println(response.PlacesList.PlaceType.get(0).Places.Place.get(0).name);
        System.out.println(response.PlacesList.PlaceType.get(0).Places.Place.get(0).description);
      }
    }
    
    class Response
    {
      PlacesList PlacesList;
    }
    
    class PlacesList
    {
      List<PlaceType> PlaceType;
    }
    
    class PlaceType
    {
      @SerializedName("-Name")
      String Name;
      Places Places;
    }
    
    class Places
    {
      List<Place> Place;
    }
    
    class Place
    {
      String name;
      String latitude;
      String longitude;
      String description;
    }
    

    Output:

    Airport
    Juhu Aerodrome
    Juhu Aerodrome is an airport that serves the metropolitan
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse json request using google GSON (on Android although this is
I want to parse this JSON string using Gson {name:name,type:[a,b,c]} is it possible? 1st
I'm parsing JSON using GSON, but get an error when I try to parse
I parse data using JSON in javascript, I find this is very convenient. But
I have the following line: 14:48 say;0ed673079715c343281355c2a1fde843;2;laka;hello ;) I parse this by using a
I am using GSON to parse a Java bean and pass the JSON string
I am using JSON.parse to parse this JSON string [{created_at:2012-01-24T22:36:21Z,name:joe,age:42,updated_at:2012-01-24T22:36:21Z}] However I am simply
I am using gson to parse json into java beans. For the API I
I'm trying to parse some JSON object strings that I'm getting using gson-1.6.jar I
So I'm using GSON to parse JSON from an API and am stuck 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.