YP
5 years agoOccasional Contributor
How to convert JSON to XML using xslt?
Hi All,
How can I convert the below JSON input request to XML format using XSLT I have tried with this XSLT from here https://www.quora.com/Is-there-a-way-to-convert-JSON-to-JSONX-without-using-IBM-DataPower but I didn't get desired output and it's throwing an error:"illegal character { at offset 0" in Datapower.
My input request:
{
"SMS": [{
"to": "+966874939494",
"Message": "<subject+message> "
},
{
"to": "+96687499490",
"Message": "<subject+message>"
}
]
}
My Expected Output:
<?xml version="1.0" encoding="UTF-8"?>
<sendReq>
<MsgRqHdr>
<RqUID>SR_123</RqUID>
<SCId>SF12</SCId>
<FuncId>36</FuncId>
<UsrId>S12</UsrId>
<Dt>2020-05-26T15:12:13</Dt>
<Service>SMS</Service>
</MsgRqHdr>
<Body>
<Com>
<Specific>
<Type>SMS</Type>
</Specific>
<CValue>
<Char>
<Name>ID</Name>
</Char>
<Value>966560329031</Value>
</CValue>
<CValue>
<Char>
<Name>Event</Name>
</Char>
<Value>subject&messagetext</Value>
</CValue>
<CValue>
<Char>
<Name>EventParam</Name>
</Char>
<Value>English</Value>
</CValue>
</Com>
</Body>
Can someone help on this please ? I never even tried Gateway script to give a try.