Javascript object re-formatting

Javascript formatting coodingdessign

asj 4 hours ago.

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..!..

Comments are closed.