How deserealizing JSON with GSON
Posted
by
loko
on Stack Overflow
See other posts from Stack Overflow
or by loko
Published on 2012-08-29T03:21:43Z
Indexed on
2012/08/29
3:38 UTC
Read the original article
Hit count: 242
I have one result of APPI http://developer.yahoo.com/geo/placefinder/guide/examples.html, I need to deserealizing the result JSON of example only with GSON http://where.yahooapis.com/geocode?location=San+Francisco,+CA&flags=J&appid=yourappid
But i dont now have to do the class for deserealizing one JSON with array This is the reponse:
{"ResultSet":
{"version":"1.0",
"Error":0,
"ErrorMessage":"No error",
"Locale":"en_US",
"Quality":40,
"Found":1,
"Results":[
{"quality":40,
"latitude":"37.779160",
"longitude":"-122.420049",
"offsetlat":"37.779160",
"offsetlon":"-122.420049",
"radius":5000,
"name":"",
"line1":"",
"line2":"San Francisco,
CA",
"line3":"",
"line4":"United States",
"house":"",
"street":"",
"xstreet":"",
"unittype":"",
"unit":"",
"postal":"",
"neighborhood":"",
"city":"San Francisco",
"county":"San Francisco County",
"state":"California",
"country":"United States",
"countrycode":"US",
"statecode":"CA",
"countycode":"",
"uzip":"94102",
"hash":"C1D313AD706E3B3C",
"woeid":12587707,
"woetype":9}]
}
}
Im trying to deserealizing of this way but i couldn´t do that, please help me to do the correct class to get the JSON with GSON.
public class LocationAddress {
private ResultSet resultset;
public static class ResultSet{
private String version;
private String Error;
private String ErrorMessage;
private List<Results> results;
}
public static class Results{
private String quality;
private String latitude;
private String longitude;
public String getQuality() {
return quality;
}
public void setQuality(String quality) {
this.quality = quality;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
}
}
© Stack Overflow or respective owner