Trying to learn how to use JSON and parse the json data.i am using google-gson API to parse my json data.
i am getting my JSON data in the following format
{"guid":{"uri":"http://social.yahooapis.com/v1/me/guid","value":"123456789"}}
and here is my parsing code using google-gson
Gson gson=new Gson();
MyGuid myGuid=new MyGuid();
myGuid=gson.fromJson(response.getBody(), MyGuid.class);
public class MyGuid {
public MyGuid() {
}
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
but i am getting the value of guid as null.
I know i am doing wrong but being new to JSON format is what making me more confused.
Any help in this regard will be helpful.
Your data structures should reflect the data you are trying to de-serialize.
For example, you could use something of this form:
The
guidproperty of the JSON is mapped to theguidproperty of theDatatype. The properties of that object are placed in aMapas strings.