On converting XML to JSON using JSON schema in “XMLStreamtoStream” mode then the output JSON has unexpected values.
XML Structure – ItemID/SupplierPartID = 273
JSON Structure – orderEntries/productcode = 73
- All the leading zeros in the source field (type - integer) were getting stripped off and the output value that is generated is transformed (kind of octal representation of the numeric value).
- In the latest version, we have a property in JSON Schema to remove leading zeros from the numeric data. But ABC is on the older version and their JSON Schema doesn't have this property. So, it was not a viable option for them for now.
- Even if you disable above property in the latest version, the output of JSON Schema is not consistent and depends on source field value. If the numeric value in source field starts with a number (not zero), then the output is an integer (without quotes), but if it starts with zero, then the output is within quotes. Maybe, this is how the API behaves but we need to further see if the output can be made consistent irrespective of source field value.
- To disable automatic conversion of numeric value to int/long which will strip out the leading zero, you can put the numeric value in CDATA and then it will work.
- To add CDATA section to any element in the Data Mapper, refer below link: