An associative array in PHP is converted to a Map in Java. So, in the eyes of Gson, your JSON is in the format Map<String, Event> , where the Event class has the status and time fields.
public class Event { private String Status; private String Time;
Yes, uppercase field names are ugly, but what your JSON looks like. Otherwise, you would need to create a custom Gson deserializer .
Here you can convert it.
Map<String, Event> events = new Gson().fromJson(json, new TypeToken<Map<String, Event>>(){}.getType());
A01 , A02 etc. become a Map , and its value becomes an Event value of a Map . You can add another custom deserializer to get time in java.util.Date .
Alternatively, you can also use Map<String, Map<String, String>> .
Balusc
source share