[
{
"MAP_COORDINATES":
"[[32.732695279933104,74.86289978027344],
[32.72749665793957,74.85431671142578],
[32.72143121579454,74.85963821411133],
[32.72200889472774,74.88521575927734]]"
}
]
如何解析这个数组。请帮忙
答案 0 :(得分:1)
将代码从JSON.parse(polyLocation).forEach(function(v) { ...
更改为JSON.parse(polyLocation[0].MAP_COORDINATES).forEach(function(v) { ...
可以解决此问题。检查Fiddle。
答案 1 :(得分:1)
Use
var cordData = JSON.parse(polyLocation);
cordData =cordData['MAP_COORDINATES'];
cordData.forEach(function(v) {
alert(v[0]);
path.push(new google.maps.LatLng(v[0],v[1]));
alert("coords main ="+path[0]);
})
答案 2 :(得分:0)
试试这个
var a ='[{"MAP_COORDINATES":"[[32.732695279933104,74.86289978027344],[32.72749665793957,74.85431671142578],[32.72143121579454,74.85963821411133],[32.72200889472774,74.88521575927734]]"}]' ;
var b =JSON.parse(a);
var data = JSON.parse(b[0].MAP_COORDINATES);
data.forEach(function(v) {
console.log(v);
})
答案 3 :(得分:0)
您需要更改您的json语法..
c
应用[0] .MAP_COORDINATES [0]
“32.732695279933104,74.86289978027344”