Hi All,
I am having an issue where from an python script I am trying to convert an xml to Json.
But The Address array appears in json only if multiple address tags are passed from xml.
I am expecting this as below But I am not getting it in a array format and I want it in that format even if its one Record of addresses. Else the record is failing in third party application. with the error..
Has anybody work on this to create json Arrays from a python script or any other in ION?
Error from third party application:
{
"code": "REQUEST_VALIDATION_ERROR",
"message": "Invalid schema for content type application/json. Errors: /addresses expected type: JSONArray, found: JSONObject. "
}
Expected Result:
"addresses": [
{
"id": "",
"ifsAddressId": "",
"addressType": "",
"street": "",
"postalCode": "",
"city": "",
"state": "",
"stateCode": "",
"country": "",
"countryCode": ""
}
],
This below is my python script
import json
import xmltodict
xml = xmltodict.parse(input_xml)
output_json = xml['BillToPartyMaster']
print(output_json)
This is the xml with address tags I am trying to convert to Json
<addresses>
<id></id>
<ifsAddressId></ifsAddressId>
<addressType></addressType>
<street></street>
<postalCode></postalCode>
<city></city>
<state></state>
<stateCode></stateCode>
<country></country>
<countryCode></countryCode>
</addresses>
This is the json output I am getting in Test window of python scripting
"addresses": {
"id": "",
"ifsAddressId": "",
"addressType": "",
"street": "",
"postalCode": "",
"city": "",
"state": "",
"stateCode": "",
"country": "",
"countryCode": ""
},