how to push nested json object into array. This is sample json object. Assume I have 100 GROUP.
data="result": {
"GROUP_A": {
"statistics": {
"year2000": 8666,
"year2001": 1213,
"year2002": 123,
},
"trending": {
"year2000": 90,
"year2001": 78,
"year2002": 86,
}
}
"GROUP_B": {
"statistics": {
"year2000": 43223,
"year2001": 4234,
"year2002": 124343,
},
"trending": {
"year2000": 34,
"year2001": 43,
"year2002": 45,
}
}
}
Example output is below:
"result": [{
"GROUP_A": [{
"statistics": {
"year2000": 8666,
"year2001": 1213,
"year2002": 123,
},
"trending": {
"year2000": 90,
"year2001": 78,
"year2002": 86,
}
}]
"GROUP_B": [{
"statistics": {
"year2000": 43223,
"year2001": 4234,
"year2002": 124343,
},
"trending": {
"year2000": 34,
"year2001": 43,
"year2002": 45,
}
}]
}]
I have no idea to do. If simple object I can push like this:
var arr=[];
arr.push(data);
Reason to push into array because the key object for group is dynamic. I want to use group for filtering data.