According to this Gson can deserialize to inner classes. I have the next fragment of JSON string:
...
"coordinates": {
"coordinates": [106.80552006,-6.22016938],
"type": "Point",
}
...
I'm using the next class:
public class Tweet {
public Coordinates coordinates = new Coordinates();
public class Coordinates {
public double[] coordinates;
}
}
and trying to parse the my JSON string:
Tweet tweet = gson.fromJson(string, Tweet.class);
Tweet.Coordinates tweetCoordinates = gson.fromJson(string, Tweet.Coordinates.class);
But I get this error:
Expected BEGIN_ARRAY but was BEGIN_OBJECT
Could you please tell me where the mistake is?
See Question&Answers more detail:os