Hello Everyone,
I am trying to generate xml data for my input json data using JSON to XML policy
My request:
"Schinfo":[{"amt":"23","code":"15","otp": "Z"}]
Code which I am using:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <JSONToXML async="false" continueOnError="false" enabled="true" name="JSON-to-XML-2"> <DisplayName>JSON to XML-1</DisplayName> <Source>request.content</Source> <OutputVariable>serializer</OutputVariable> <Properties/> <Options> <OmitXmlDeclaration>true</OmitXmlDeclaration> <ArrayRootElementName>ROOT</ArrayRootElementName> <ArrayItemElementName>SchInfo</ArrayItemElementName> </Options> </JSONToXML>
My Response:
<Root> <Schinfo> <Code>15</code> <Opt>Z</SchOptCode> <amt>101</amt> </Schinfo> </Root>
But My expected xml data should be in below format
<ROOT> <Schinfo> <Code>1565</code> <Opt>Z</SchOptCode> <amt>101</amt> </Schinfo> </ROOT>
Root tag should in caps <ROOT>
Can anyone please on this.
Thank You,
Lakshmi Motupalli
There's an Options element that does this for you.
<JSONToXML name="JSON-to-XML-2"> <Source>request.content</Source> <OutputVariable>serializer</OutputVariable> <Options> <OmitXmlDeclaration>true</OmitXmlDeclaration> <!-- add the following --> <ObjectRootElementName>ROOT</ObjectRootElementName> <!-- the following applies to arrays only. --> <ArrayRootElementName>ROOT</ArrayRootElementName> <ArrayItemElementName>SchInfo</ArrayItemElementName> </Options> </JSONToXML>
Hello Everyone,
Now I am getting <ROOT> tag as response by using the below line in JSON to XML policy
<ObjectRootElementName>ROOT</ObjectRootElementName>
Thank you,
Lakshmi