给出以下查询:
{"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}]}}
如何获得“uzip”?
alert(data.ResultSet.Results)有效
但:
警报(data.ResultSet.Results.uzip)
说'undefined'
警报也是如此(data.ResultSet.Results [uzip])。
感谢。
答案 0 :(得分:2)
那里有一个阵列。像这样访问它......
data.ResultSet.Results[0].uzip
答案 1 :(得分:1)
尝试data.ResultSet.Results[0].zip
注意Results数组包含一个对象,您需要获取数组中的第一个元素,然后访问其中的组件。
答案 2 :(得分:1)
data.ResultsSet.Results[0].uzip
怎么样?