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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:52:51+00:00 2026-06-06T05:52:51+00:00

I like to use GSON to deserialize the following JSON String. { type: FeatureCollection,

  • 0

I like to use GSON to deserialize the following JSON String.

{
  "type": "FeatureCollection",
  "features": [
    {
      "id": "FSROGD.4440181",
      "geometry": {
        "type": "Point",
        "coordinates": [
          16.7594706041998,
          43.148716514354945
        ]
      }
    }
  ]
}

I already prepared the neccessary Java classes named Response, Features, Geometry and Coordinates. Besides the last class everything works fine. But for Coordinates, I do not understand what I should write since there are no keys given that I could prepare as member variables.
Here are the parent Geometry class …

package info.metadude.trees.model.vienna;    
import com.google.gson.annotations.SerializedName;

public class Geometry {     
    @SerializedName("type")
    public String type;

    // TODO: Prepare Coordinates class for GSON.
    // @SerializedName("coordinates")
    // public Coordinates coordinates;
}

… and the empty Coordinates class.

package info.metadude.trees.model.vienna;    
public class Coordinates {
    // TODO: No idea what should be defined here.
}
  • 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-06T05:52:52+00:00Added an answer on June 6, 2026 at 5:52 am

    You could use coordinates as a collection property in Geometry. This would automatically map the values to the right property.

    import java.util.List;
    
    import com.google.gson.Gson;
    
    public class GSonTest {
    
        public static void main(final String[] args) {
            Gson gson = new Gson();
            System.out.println(gson.fromJson("{        \"type\": \"Point\",        \"coordinates\": [          16.7594706041998,          43.148716514354945        ]      }", Geometry.class));
        }
    
        public static class Geometry {
    
            List<Float> coordinates;
    
            public List<Float> getCoordinates() {
                return coordinates;
            }
    
            public void setCoordinates(final List<Float> coordinates) {
                this.coordinates = coordinates;
            }
    
            @Override
            public String toString() {
                return "Geometry [coordinates=" + coordinates + "]";
            }
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a json string like this: http://pastebin.com/ckUZadwL I'm trying to use gson to
I would like use a panel whose children have coordinates specified as percentage of
I don't like Jackson. I want to use ajax but with Google Gson. So
When Parsing JSON I normally just constuct an object and use the gson library
Designing my RESTful API, I would like use following URI http://[HOST]/[PLANET]/[LAT];[LONG] e.g. http://myserver/earth/50.2;29.1 What
I try to use gson library to deserialize a flow of objects sent to
I'm trying to use gson to convert this returned JSON into some kind of
I would like to serialize this object to JSON String public class Person {
i would like use a variable session ($_session) but it doesn't work in Drupal
I like to use parameter for FILENAME in the code below, instead of N'D:\DBName.mdf'

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.