Trying to parse this data:
{ id: 'abc',
name: 'abc',
'24h_total': '370029.0',
last_updated: '1501633446' }
Trying to run this code on the above rest api response.....
var jsondata = JSON.parse(body);
var values = [];
console.log(jsondata);
for(var i=0; i< jsondata.length; i++){
//how do i access this property?
console.log(jsondata[i].24h_total);
}
at the moment i get an error
jsondata[i].24h_total,
^^^
SyntaxError: Invalid or unexpected token
I am sure it's due to the fact that this field name starts with a number.
thanks in advance.
{"id":"abc","name":"abc","24h_total":"370029.0","last_updated":"1501633446"}.. note ... all keys and all strings enclosed in"..."...'...'is not valid JSON