Hi I have a json from http request, the server json response is this:
{
"map": {
"03/04": 13,
"05/04": 41,
"06/04": 1,
"12/04": 4,
"14/04": 7,
"18/04": 8,
"19/04": 2,
"22/04": 1,
"25/04": 4
},
"links": []
}
I want to split dates in 1 array and values in other array, At the end I want : Data[03/04,05/04,06/04....] and Val[13,41,1....] is it possible without difficult implementation?
This could be an approach:
private Data = [];
private Val = [];
for (let key in data) {
this.Data.push(key);
this.Val.push(data[key])
}
you can use this
var a=`{
"map": {
"03/04": 13,
"05/04": 41,
"06/04": 1,
"12/04": 4,
"14/04": 7,
"18/04": 8,
"19/04": 2,
"22/04": 1,
"25/04": 4
},
"links": []
}`
var Data=[];
var val=[]
for(each in a.map){
Data.push(each);
val.push(a.map[each]);
}
let date = Object.keys(JsonRespond.map) // get all keys in map object
let value = [];
date.forEach((key) => {
value.push(JsonRespond.map[key]);
})