我试图通过关键字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)
}