i have a json file which goes like below
[{
    "data": {
        "aggregations": {
            "openissue": {
                "buckets": [{
                        "doc_count": 5,
                        "date": "25 aug"
                    },
                    {
                        "doc_count": 6,
                        "date": "26 aug"
                    },
                    {
                        "doc_count": 7,
                        "date": "27 aug"
                    },
                    {
                        "doc_count": 8,
                        "date": "28 aug"
                    }
                ]
            }
        }
    },
    "a": "not needed",
    "b": "not needed"
},
{
    "data": {
        "aggregations": {
            "closeissue": {
                "buckets": [{
                        "doc_count": 9,
                        "date": "29 aug"
                    },
                    {
                        "doc_count": 10,
                        "date": "30 aug"
                    },
                    {
                        "doc_count": 11,
                        "date": "31 aug"
                    },
                    {
                        "doc_count": 12,
                        "date": "1 sept"
                    }
                ]
            }
        }
    },
    "a": "not needed",
    "b": "not needed"
}, {
    "data": {
        "aggregations": {
            "pendingissue": {
                "buckets": [{
                        "doc_count": 13,
                        "date": "10 sept"
                    },
                    {
                        "doc_count": 14,
                        "date": "13 sept"
                    },
                    {
                        "doc_count": 15,
                        "date": "18 sept"
                    },
                    {
                        "doc_count": 16,
                        "date": "19 sept"
                    }
                ]
            }
        }
    },
    "a": "not needed",
    "b": "not needed"
}
]
the Number of objects are dynamic which i am getting by ajax call,This json is created after the ajax call.I am trying to filter out and the json to a desired format where the number of object depends on the number of date.
the Desired output should be something like
    [
  {
    "Key_as_string": "25aug",
    "values": [
      {
        "label": "open-issues",
        "doc_count": 10
      },
      {
        "label": "closed-issues",
        "doc_count": 10
      },
      {
        "label": "exempted-issues",
        "doc_count": 10
      }
    ]
  },
  {
    "Key_as_string": "26aug",
    "values": [
      {
        "label": "open-issues",
        "doc_count": 10
      },
      {
        "label": "closed-issues",
        "doc_count": 10
      },
      {
        "label": "pending-issues",
        "doc_count": 10
      }
    ]
  }
]
How do i do it using javascript or jquery
 
    