我有一個響應對象,它看起來是這樣的 -解析JSON字符串響應。已經嘗試JSON.parse()來
{
location: '{country:Poland,latitude:50.0575,longitude:19.9802}',
ip: '83.26.234.177',
name: 'John Doe'
}
我想讀的國名這樣的 -
data.forEach(function(datapoint) {
dataObject.ip = datapoint.ip;
var locationObject = datapoint.location; // also tried JSON.parse
console.log(locationObject); //{country:Poland,latitude:50.0575,longitude:19.9802}
console.log(locationObject.country); // undefined
console.log(locationObject.latitude); //undefined
console.log(locationObject.longitude); //undefined
}
越來越undefined
。
您的位置屬性是字符串。 –
它在哪裏變得不明確? –
是的,不認爲有效json –