Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

XML to JSON conversion

Hello Everyone,

I have one xml as input having multiple nested elements and I need to convert that xml into JSON document to load it into Couchbase using Talend. Below is my sample XML document.

<?xml version='1.0' encoding='UTF-8'?>
<xml>
<entities>
<entity id="5" version="123456">
<name>ABC</name>
<listCode>OF</listCode>
<address>MH INDIA</address>
<address>GJ INDIA</address>
<cd name="ID">1234</cd>
<cd name="SRC">XYZ</cd>
</entity>
</entities>
</xml>

Expected output:
"entity":{
"id":"5",
"version":"123456",
"name":"ABC",
"listCode":"OF",
"address": [{address1:"MH INDIA"},{address2:"GJ INDIA"}]
"sdf":[
{
"sdfvalue":"1234",
"sdfname":"ID"
},
{
"sdfvalue":"XYZ",
"sdfname":"Src"
}
]
}

I am getting output as 2 different JSON document, one for combination of "sdfvalue":"1234","sdfname":"ID" and second document for combination of "sdfvalue":"XYZ","sdfname":"Src"  like below....

"entity":{
"id":"5",
"version":"123456",
"name":"ABC",
"listCode":"OF",
"address": [{address1:"MH INDIA"},{address2:"GJ INDIA"}]
"sdf":[
{
"sdfvalue":"1234",
"sdfname":"ID"
}
]
}

"entity":{
"id":"5",
"version":"123456",
"name":"ABC",
"listCode":"OF",
"address": [{address1:"MH INDIA"},{address2:"GJ INDIA"}]
"sdf":[
{
"sdfvalue":"XYZ",
"sdfname":"Src"
}
]
}

I want output in single JSON document. Can anyone suggest me few ideas to implement it in Talend.

Labels (4)
1 Reply
Anonymous
Not applicable
Author

Please check out tXmlToJson custom component in talend exchange center.

https://exchange.talend.com/#marketplaceproductoverview:marketplace=marketplace%252F1&p=marketplace%...