I'm having some trouble with GSON, mainly deserializing from JSON to a POJO.
I have the following JSON:
{
"events":
[
{
"event":
{
"id": 628374485,
"title": "Developing for the Windows Phone"
}
},
{
"event":
{
"id": 765432,
"title": "Film Makers Meeting"
}
}
]
}
With the following POJO's ...
public class EventSearchResult {
private List<EventSearchEvent> events;
public List<EventSearchEvent> getEvents() {
return events;
}
}
public class EventSearchEvent {
private int id;
private String title;
public int getId() {
return id;
}
public String getTitle() {
return title;
}
}
... and I'm deserializing with the following code, where json input is the json above
Gson gson = new Gson();
return gson.fromJson(jsonInput, EventSearchResult.class);
However, I cannot get the list of events to populate correctly. The title and id are always null. I'm sure I'm missing something, but I'm not sure what. Any idea?
Thanks