java - Jackson deserializing GMaps JSON -
i trying deserialize following json: http://maps.googleapis.com/maps/api/geocode/json?address=04545-006
my doubt is, how deserialize in way results.geometry.location.lat , results.geometry.location.lng ?
since using spring, tried using resttemplate , annotate helper class follow, without success:
public class gmapsdto { t@jsonproperty("results/geometry/location/lat") private string lat; @jsonproperty("results.geometry.location.lng") private string lng; public string getlat() { return lat; } public void setlat(string lat) { this.lat = lat; } public string getlng() { return lng; } public void setlng(string lng) { this.lng = lng; } }
is there way navigate through object tree , info need?
thanks.
you want able use simple navigation via annotations, there has been jira issue reported @jsonwrapped annotation, opposite @jsonunwrapped, you're saying http://jira.codehaus.org/browse/jackson-781. in humble opinion simplest way navigate tree , lean on jsonnode, like
jsonnode rootnode = mapper.readvalue(gmapjson, jsonnode.class); system.out.println(rootnode.findvalues("location"));
Comments
Post a Comment