我試圖通過關鍵字lat
從JSON文件訪問特定值,因爲我循環遍歷每條記錄。但是,我印刷它們時得到的結果是undefined
。
JSON
[{"pid":4317129482,"lat":"51.5078","lon":"-0.10467","coords":{"x":-0.10467,"y":51.5078},"points":{"x":-0.10467,"y":51.5078}},
{"pid":4356791546,"lat":"51.522","lon":"-0.101773","coords":{"x":-0.101773,"y":51.522},"points":{"x":-0.101773,"y":51.522}},
的JSON存儲在data
代碼試圖
$.each(data, function(key, value){
if (key == "lat") {
console.log(value)
}
OR
$.each(data, function(item){
console.log(item.lat)
}