Reputation: 23360
given the following query:
{"ResultSet":{"version":"1.0","Error":0,"ErrorMessage":"No error","Locale":"us_US","Quality":40,"Found":1,"Results":[{"quality":40,"latitude":"37.777125","longitude":"-122.419644","offsetlat":"37.777125","offsetlon":"-122.419644","radius":10700,"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":"","woeid":2487956,"woetype":7}]}}
how do I get the "uzip"?
alert(data.ResultSet.Results) works
but:
alert(data.ResultSet.Results.uzip)
says 'undefined'
and so does alert(data.ResultSet.Results[uzip]).
thanks.
Upvotes: 2
Views: 185
Reputation: 20602
Try data.ResultSet.Results[0].zip
Note the Results array contains an object, you need to take the first element in the array, and then access the component within it.
Upvotes: 1
Reputation: 490153
There's an array in there. Access it like so...
data.ResultSet.Results[0].uzip
Upvotes: 2