Hello;
I have an issue with XML to JSON transformation
<AAA> <isSecure>false</isSecure> <ID>J13609</ID> </AAA> <BBB> <ID>17E946</ID> </BBB>
and my XMLtoJSON policy as
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <XMLToJSON async="false" continueOnError="false" enabled="true" name="x2jTransformation"> <DisplayName>x2jTransformation</DisplayName> <Options> <RecognizeNumber>true</RecognizeNumber> <RecognizeBoolean>true</RecognizeBoolean> <RecognizeNull>true</RecognizeNull> <NullValue>NULL</NullValue> <TextNodeName>TEXT</TextNodeName> <AttributePrefix>@</AttributePrefix> </Options> <OutputVariable>response</OutputVariable> <Source>response</Source> </XMLToJSON>
however, I get below JSON. Those ID's are String but the 2nd one is transformed as Integer
"AAA": { "isSecure": false, "ID": "J13609" }, "BBB": { "ID": 17E946 }
I have to use RecognizeNumber feature in the policy since I have other fields, In my opinion, either the field '17E946' is recognized as HEX or exponential.
How can I solve the issue?
Thanks
Answer by Dino-at-Google
·
Feb 19, 2019 at 05:52 PM
Unfortunately it is not possible to apply the RecognizeNumber option to a subset of the XML input. Either everything that looks like a number is recognized as a number, or nothing is.
Therefore, I would suggest that you disable the RecognizeNumber option, and then, apply a post-processing JavaScript step that would "manually" convert the numbers that you know are numbers.
Thank You Dino, I was thinking js solution if I can't find anything. I will implement the scenario then
Thanks
Regards
How can I tell Apigee Edge to emit a "pretty printed" JSON payload? 3 Answers
XML to JSON policy data conversion issue, 0123 not being treated as an integer 1 Answer
How to routes 2 or more TargetEndPoints based on request body using Postman in apigee? 2 Answers
Parse XML response with special characters as valid xml 1 Answer
Why doesn't my XML to JSON policy work? 2 Answers