XML To Json Conversion

book

Article ID: 103785

calendar_today

Updated On:

Products

CA API Gateway (Layer 7) SA94 to API SECURITY STARTER PACK-7 CA Rapid App Security MOBILE API GATEWAY CA Mobile - API Gateway CA API Gateway

Issue/Introduction



Users publish soap/xml services by converting them to rest/json.
They use 'Apply Json Transformation' assertion to convert xml to json.  In some cases, the same field converted as an object and array at the same response.
I have added a screenshot that explains the situation.
How can we fix this conversion issue? 

 

Environment

ENV: 9.3

Resolution

This issue is not related to ordering. The values of duplicate tags at the same level in XML are being combined into an array, where if there's only one tag it's converted to an object. This is a common way JSON libraries handle duplicate field names in an object. 

While the official JSON standard does not forbid duplicate keys, it is discouraged and there is no requirement for them to be supported. 

This Stack Overflow answer explains and gives sources for this very clearly:
https://stackoverflow.com/a/23195243/2631689 

Attachments

1558536542278apiResponse.jpg get_app