Here's an example using Google Gson.
public class MyObject { private String id; private String name; // Getters public String getId() { return id; } public String getName() { return name; }}
And to access it:
MyObject obj = new Gson().fromJson(jsonString, MyObject.class);System.out.println("ID: "+obj.getId());System.out.println("Name: "+obj.getName());
As far as the best way, well that's subjective. This is one way you can accomplish what you need.