Skip to content

Instantly share code, notes, and snippets.

@jeetmp3
Last active September 8, 2016 05:01
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
public class GsonDeserializer {
public static void main(String []args) {
Gson gson = new Gson();
GenericResponse<UserResponse> response = gson.fromJson(jsonString, new TypeToken<GenericResponse<UserResponse>>(){}.getType());
System.out.println(response.getData().getName());
System.out.println(response.getData().getEmail());
GenericResponse<SocialAccountsResponse> socialAccountResponse = gson.fromJson(jsonString, new TypeToken<GenericResponse<SocialAccountsResponse>>(){}.getType());
System.out.println(socialAccountResponse.getData().getId());
System.out.println(socialAccountResponse.getData().getProfileUrl());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment