这就是我现在拥有的......我必须改变结构以满足我的需求......
{
"value": [
{
"Latitude": 1.29997,
"Longitude": 103.8225
},
{
"Latitude": 1.30786,
"Longitude": 103.75999
}
]
}
这就是我需要的......
{
"features": [
{ "geometry": { "type": "Point", "coordinates": [ 103.83697, 1.33502 ] } },
{ "geometry": { "type": "Point", "coordinates": [ 103.8586, 1.31584 ] } },
{ "geometry": { "type": "Point", "coordinates": [ 103.86744, 1.35397 ] } }
]
}
答案 0 :(得分:0)
在JavaScript中,您可以使用map
function:
var obj = {
'value': [
...
]
};
var newObj = {}
newObj.features = obj.value.map(function (elt) {
return {
'geometry': {
'type': 'Point',
'coordinates': [
elt.Latitude,
elt.Longitude
]
}
}
})
console.log(newObj)