I have the following JSON structure :
{
"userId": "55",
"Unit": [
{
"id": "1",
"unitname": "unit1",
"eventId": "2",
"transactiontype": "1"
},
{
"id": "2",
"unitname": "unit2",
"eventId": "2",
"transactiontype": "1"
},
{
"id": "3",
"unitname": "unit3",
"eventId": "2",
"transactiontype": "2"
}
]
}
and I need to convert it to the below XMl format :
<Units userId="55">
<Unit id="1" unitname="unit1" eventId="2" transactiontype="1"/>
<Unit id="2" unitname="unit2" eventId="2" transactiontype="1"/>
<Unit id="3" unitname="unit3" eventId="2" transactiontype="2"/>
</Units>
While trying it through java I ma getting an XML but it shows XML elements as below :
<UnitId>1</UnitId>
Can someone please help me as to what needs to be done so that I get the XML format needed, i.e as attributes.