I am trying to parse a json response
[{
"province": "abc",
"county": "aa",
"timeline": {
"cases": {
"4/11/20": 4,
"4/12/20": 5
},
"recover": {
"4/11/20": 0,
"4/12/20": 1
}
}
}]
Although I am able to get "county" value but I am not able to go into timline data.Its either giving me undefined issue or giving [obejct Object] as log. Below I my code.
parseTimeLineData(resData)
{
let timeLine = [];
resData.map(data =>
{
let dd = data.timeline;
Object.keys(dd).map((key, i) => {
var one = {key}
alert(one);
var value = dd[key]
})
});
}
My requirement is to parse the cases and recover nodes and save them in separate array to be used further. Also need to know how to only fetch first index values out of a big array.
valuein your function is an object?JSON.stringifybelongs to JS. If I'm not mistaken with the provided answer you get an array of array, which I think is not the desired output.