Unexpected Values in JSON when converted from XML using JSON Schema

Issue:

On converting XML to JSON using JSON schema in “XMLStreamtoStream” mode then the output JSON has unexpected values.

E.g.

XML Structure – ItemID/SupplierPartID = 273

JSON Structure – orderEntries/productcode = 73

Cause

  1. 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).
  2. 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.
  3. 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.

Solution:

  1. 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.
  2. To add CDATA section to any element in the Data Mapper, refer below link:

https://docs.adeptia.com/display/AS/Adding+a+Character+Data+%28CData%29+Section

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.