I've tried a couple hours to find a way to handle JSON like this:
[
{
"value": "Osteonecrosis",
"Diagnosis_Code": "DIAG002",
"NamaCategory": "Primary Category",
"FK_Diagnosis_Content_ID": 2
},
{
"value": "Malunion",
"Diagnosis_Code": "DIAG002",
"NamaCategory": "Healing",
"FK_Diagnosis_Content_ID": 19
},
{
"value": "Osteonecrosis",
"Diagnosis_Code": "DIAG004",
"NamaCategory": "Primary Category",
"FK_Diagnosis_Content_ID": 2
},
{
"value": "Malunion",
"Diagnosis_Code": "DIAG004",
"NamaCategory": "Healing",
"FK_Diagnosis_Content_ID": 19
}
]
I want to add an array Below NameCategory just in case the NameCategory value is duplicate, so the expected result would be:
[
{
"NamaCategory": "Primary Category",
"value":[
{
"value": "Osteonecrosis",
"Diagnosis_Code": "DIAG002",
"FK_Diagnosis_Content_ID": 2
},
{
"value": "Osteonecrosis",
"Diagnosis_Code": "DIAG004",
"FK_Diagnosis_Content_ID": 2
}
]
},
{
"NamaCategory": "Healing",
"value":[
{
"value": "Malunion",
"Diagnosis_Code": "DIAG002",
"FK_Diagnosis_Content_ID": 19
},
{
"value": "Malunion",
"Diagnosis_Code": "DIAG004",
"FK_Diagnosis_Content_ID": 19
}
]
}
]
I'm not familiar to handling JSON, so I need help here,
anyone can help me how to handling those json?
NamaCategoryrather thanNameCategory