I have to interact with an API, and the response format (from what I\'ve read) seems to be poorly structured. I\'ve found a google groups reply to a somewhat similiar probl
The JSON objects {} can be represented by a Map<String, Object> or a Javabean class. Here's an example which uses a Javabean.
public class ResponseData {
private Response response;
// +getter+setter
public static class Response {
private int reference;
private Data data;
// +getters+setters
}
public static class Data {
private User user;
// +getter+setter
}
public static class User {
private String id;
private String firstName;
private String lastName;
private String email;
private String phone;
private Linkedid linkedid;
// +getters+setters
}
public static class Linkedid {
private String id;
// +getter+setter
}
}
Use it as follows:
ResponseData responseData = new Gson().fromJson(json, ResponseData.class);