After spending a few hours trying to figure out how to manage JSON data structured 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 would like to create an array under the NameCategory
property in case the NameCategory
value is duplicated. The expected output should be as follows:
[
{
"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
}
]
}
]
Since I am not very familiar with handling JSON, I am seeking assistance,
Can anyone provide guidance on how to manipulate this JSON data?