Getting invalid json while converting xml to json.

Below is the XML data.

<Body>
    <AccNum>000405010255</AccNum>
    <AccNum>000405010310</AccNum>
    <AccNum>000405009777</AccNum>
    <AccNum>000401109537</AccNum>
    <AccNum>000401113460</AccNum>
    <AccNum>000401116861</AccNum>
    <AccNum>001805015288</AccNum>
    <AccNum>628801537715</AccNum>
    <AccNum>000319000184</AccNum>
    <AccNum>000401193586</AccNum>
    <AccNum>000405111139</AccNum>
    <AccNum>000405501186</AccNum>
    <AccNum>000760004994</AccNum>
    <AccNum>000805015689</AccNum>
    <AccNum>000813001320</AccNum>
    <AccNum>001105024982</AccNum>
    <AccNum>001801080623</AccNum>
    <AccNum>001810042371</AccNum>
    <AccNum>001825075268</AccNum>
    <AccNum>004214109637</AccNum>
    <AccNum>004214109638</AccNum>
    <AccNum>010310000278</AccNum>
    <AccNum>032501004151</AccNum>
    <AccNum>044205008102</AccNum>
    <AccNum>105701000275</AccNum>
    <AccNum>630010075140</AccNum>
</Body>

While converting XML to JSON I'm getting the below data.

{
    "Body": {
        "AccNum": [
            "000405010255",
            "000405010310",
            "000405009777",
            "000401109537",
            "000401113460",
            "000401116861",
            "001805015288",
            628801537715,
            "000319000184",
            "000401193586",
            "000405111139",
            "000405501186",
            "000760004994",
            "000805015689",
            "000813001320",
            "001105024982",
            "001801080623",
            "001810042371",
            "001825075268",
            "004214109637",
            "004214109638",
            "010310000278",
            "032501004151",
            "044205008102",
            105701000275,
            630010075140
        ]
    }
}

In above JSON data in few numbers i'm not getting in " ". How can i solve this issue?

Solved Solved
0 1 90
1 ACCEPTED SOLUTION

It's processing numbers where possible.

I'm assuming you're using the default configuration which is set to the "yahoo" format. This format sets the RecognizeNumber option as true, so it processes numbers where possible.

https://docs.apigee.com/api-platform/reference/policies/xml-json-policy#format-yahoo

It seems this isn't what you want, so instead remove the format option and manually set the options as required eg

<Options>
    <RecognizeNumber>false</RecognizeNumber>
</Options>

View solution in original post

1 REPLY 1

It's processing numbers where possible.

I'm assuming you're using the default configuration which is set to the "yahoo" format. This format sets the RecognizeNumber option as true, so it processes numbers where possible.

https://docs.apigee.com/api-platform/reference/policies/xml-json-policy#format-yahoo

It seems this isn't what you want, so instead remove the format option and manually set the options as required eg

<Options>
    <RecognizeNumber>false</RecognizeNumber>
</Options>