How to do Javascript object re-formatting
<pre>I have data as follows:
{
"2011":{
"01":{
"01":[
{
"date":"2011-01-01"
},
{
"date":"2011-01-02"
}
]
},
"02":{
"01":[
{
"date":"2011-02-02"
}
],
"03":[
{
"date":"2011-02-15"
},
{
"date":"2011-02-17"
}
]
}
},
"2012":{
"01":{
"01":[
{
"date":"2012-01-01"
}
]
},
"03":{
"01":[
{
"date":"2012-03-03"
}
]
}
}
}
I need to construct final data in the below format:
[{year:2011,month:'Jan',week_no:1, week_total:2},
{year:2011,month:'Jan',week_no:2, week_total:2},
{year:2012,month:'Jan',week_no:1, week_total:1}
{year:2012,month:'Mar',week_no:1, week_total:1}]
Purpose is to obtain Year/Month / Week-wise totals. This data is required to plot some charts later. Help on this is highly appreciated..!..
##Article you may like:##
1.Extension to allow users to easily identify phishing attempts
2.Prefetching and dynamic routing with Next.js