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.
}
You could use
coordinatesas a collection property inGeometry. This would automatically map the values to the right property.