[英]Convert 2 JSON objects into single javascript array Angularjs
[英]Convert Json objects to single array
这是我正在寻找的
markers: marker[] = [
{
lat: 18.533989,
lng: 73.825592,
},
{
lat: 18.540474,
lng: 73.837510,
label: 'B',
},
{
lat: 18.540972,
lng: 73.832146,
label: 'C'
}
]
}
这就是我尝试过的
for (let i = 0; i < res.length; i++) {
// Iterate over numeric indexes from 0 to 5, as everyone expects.
let newobj = res[i].destinationAddress.location.coordinates;
console.log(newobj);
for(let j = 0; j < res.length; j ++){
this.markersArr.push(newobj[j]);
}
我正在使用angular 6我需要将json obj转换为数组
在内部循环中尝试此代码。
const [lat, lng] = newobj[j];
this.markersArr.push({
lat : lat,
lng : lng,
label : 'C' // or whatever value you want to add
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.