XML to JSON issue with only alpha numeric char

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

Solved Solved
0 2 223
1 ACCEPTED SOLUTION

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.

View solution in original post

2 REPLIES 2

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