cancel
Showing results for 
Search instead for 
Did you mean: 

To convert Json to XML with multiple attribute elements with ids and values

plviji
New Contributor

 

Json: 
"name": "Company Name",
"addressLine1": "10 North Street",
"addressLine2": null,
"city": "Washington",
"state": "DC",
"postalCode": "12345",
"country": "USA"

Expected XML:
<VocabularyElement id="urn:epc:id:sgln:77777.111111.0"> <attribute id="urn:epcglobal:cbv:mda#name">Company Name</attribute> <attribute id="urn:epcglobal:cbv:mda#streetAddressOne">10 North Street</attribute> <attribute id="urn:epcglobal:cbv:mda#streetAddressTwo">Room 378</attribute> <attribute id="urn:epcglobal:cbv:mda#city">Washington</attribute> <attribute id="urn:epcglobal:cbv:mda#state">DC</attribute> <attribute id="urn:epcglobal:cbv:mda#postalCode">12345</attribute> <attribute id="urn:epcglobal:cbv:mda#countryCode">USA</attribute> </VocabularyElement>

I have tried using XML generator with the expected XML, able to get the expected result, but when I pass it through AS2 sender, it adds element=3d in all tags.
So I started using XML formatter, not able to get the expected XML tags.


<VocabularyElement>
<name>Company Name</name>
<addressLine1>10 North Street</addressLine1>
<addressLine2/>
<city>Washington</city>
<state>DC</state>
<postalCode>12345</postalCode>
<country>USA</country>
</VocabularyElement>

Can anyone help me on this?

2 REPLIES 2

Abhishek_Soni37
Contributor

Hi @plviji ,

I created a sample pipeline with what you mentioned and I invoked this pipeline in POSTMAN. The result XML doesn't have element=3d in any tags.

Could it be possible that it is getting appended in the target system?

Below is the response from Postman:

Abhishek_Soni37_0-1705306247393.png

XML Generator:

Abhishek_Soni37_1-1705306516795.png

Mapper Expression:

Abhishek_Soni37_2-1705306553709.png

Make sure the output view of mapper is binary.

Abhishek_Soni37_3-1705306605065.png

Hope this helps.

Thanks,

Abhishek

plviji
New Contributor

Hi Abhishek_Soni37,

Once I convert thru XML Generator - I have to send the file thru AS2 sender - that's were element=3d getting added to all tags