Given the following data format, how can the data be grouped by their keys?
The format of the data is:
data=[
{
"billingid": 138,
"amount": "800",
"billamount": "200",
"balance": "1",
"paid": "810",
"billdate": "Apr 2, 2014 12:00:00 AM",
"tax": "11",
"patientid": "TMCH17",
"configid": 6,
"paymenttype": "cash",
"servicename": "Room",
"firstname": "kannan"
},
{
"billingid": 138,
"amount": "800",
"billamount": "500",
"balance": "1",
"paid": "810",
"billdate": "Apr 2, 2014 12:00:00 AM",
"tax": "11",
"patientid": "TMCH17",
"configid": 3,
"paymenttype": "cash",
"servicename": "Lab",
"firstname": "kannan"
},
{
"billingid": 138,
"amount": "800",
"billamount": "100",
"balance": "1",
"paid": "810",
"billdate": "Apr 2, 2014 12:00:00 AM",
"tax": "11",
"patientid": "TMCH17",
"configid": 1,
"paymenttype": "cash",
"servicename": "Consultation",
"firstname": "kannan"
}]
The expected output is:
[{
"billingid": 138,
"amount": "800",
bamount:[{
"billamount": "100",
"billamount": "200",
"billamount": "300"
}],
"balance": "1",
"paid": "810",
"tax": "11",
"patientid": "TMCH17",
"configid": 1,
"paymenttype": "cash",
service[{
"servicename": "Consultation",
"servicename": "room",
"servicename": "lab",
}],
"firstname": "kannan"
}]
See Question&Answers more detail:
os