Sample json object for tarnsformation:
{
“order”: {
“orderid”: 1,
“orderProps”: [
{
“Category 1”: “Marine”,
“Date 1”: “31/03/2003”,
“Date 2”: “31/12/2021”,
“Paid”: 10,
“OS”: 4
},
{
“Category 1”: “Marine”,
“Date 1”: “31/03/2003”,
“Date 2”: “31/12/2021”,
“Paid”: 13,
“OS”: 5
},
{
“Category 1”: “Marine”,
“Date 1”: “31/12/2021”,
“Date 2”: “31/03/2022”,
“Paid”: 2,
“OS”: 5
},
{
“Category 1”: “Engineering”,
“Date 1”: “31/03/2005”,
“Date 2”: “31/12/2022”,
“Paid”: 134,
“OS”: 533
},
{
“Category 1”: “Engineering”,
“Date 1”: “31/03/2005”,
“Date 2”: “31/12/2022”,
“Paid”: 387,
“OS”: 4221
},
{
“Category 1”: “Engineering”,
“Date 1”: “31/12/2021”,
“Date 2”: “31/03/2022”,
“Paid”: 134,
“OS”: 533
}
]
}
}
I have used below solution but that is only for json array.
/questions/75520901/how-to-transform-json-to-json-by-using-xslt-in-java#:~:text=XSLT%203.0%20has%20basically%20two,into%20the%20XML%20representation%20of
Out put json object after transformation:
{
“order”: {
“orderid”: 1,
“orderProps”: [
{
“Date 2”: “31/12/2021”,
“OS”: 9,
“Paid”: 23,
“Category 1”: “Marine”,
“Date 1”: “31/03/2003”
},
{
“Date 2”: “31/03/2022”,
“OS”: 5,
“Paid”: 2,
“Category 1”: “Marine”,
“Date 1”: “31/12/2021”
},
{
“Date 2”: “31/12/2022”,
“OS”: 4754,
“Paid”: 521,
“Category 1”: “Engineering”,
“Date 1”: “31/03/2005”
},
{
“Date 2”: “31/03/2022”,
“OS”: 533,
“Paid”: 134,
“Category 1”: “Engineering”,
“Date 1”: “31/12/2021”
}
]
}
}
Yadav_Jogi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.