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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Convert XML to JSON in mediation route

Hi,

 

I would like to transform an XML to JSON in a route.

 

I created a basic route:

0683p000009LqrW.png

 

With my first cFile, I pick up a XML file.

 

In my cJavaDSLProcessor, I entered (According to http://camel.apache.org/xmljson.html😞

0683p000009Lqrb.png

 

And my second cFile component is supposed to put down my JSON file.

 

In my cConfig component, I added this jar:

-camel-xmljson-alldep-2.16.3.jar

 

  

 But I get this exception "java.lang.NoClassDefFoundError: nu/xom/Serializer" when running the route...

 

Eric

Labels (5)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I fixed the issue adding these three jars:

-xom-1.2.7.jar (Without it I have this exception "java.lang.NoClassDefFoundError: nu/xom/Serializer"
-commons-lang-2.6.jar (Without it I have this exception "java.lang.NoClassDefFoundError0683p000009MA5A.pngrg/apache/commons/lang/exception/NestableRuntime" )
-commons-collections-3.2.2.jar (Without it have this exception "java.lang.ClassNotFoundException: org.apache.commons.collections.map.ListOrderedMap")

 

It works now.

 

Eric

View solution in original post

3 Replies
Anonymous
Not applicable
Author

I fixed the issue adding these three jars:

-xom-1.2.7.jar (Without it I have this exception "java.lang.NoClassDefFoundError: nu/xom/Serializer"
-commons-lang-2.6.jar (Without it I have this exception "java.lang.NoClassDefFoundError0683p000009MA5A.pngrg/apache/commons/lang/exception/NestableRuntime" )
-commons-collections-3.2.2.jar (Without it have this exception "java.lang.ClassNotFoundException: org.apache.commons.collections.map.ListOrderedMap")

 

It works now.

 

Eric

Anonymous
Not applicable
Author

Hi Eric,

Hi,

I have an xml which contains some tags empty ,i want to populate this empty tags(</city>) with some value like 'NNNNNNNNNNN' and generate an xml as output(<city>NNNNN</city>).I am using tadvancedxmloutput command and Talend open studio for big data, but i was able to loop only one sub element at a time,can some one help how to process this.

Below are my xml input and expected xml output format.

 

input xml :::::::::

<emp>
<id>985426</id>
<fname>jai</fname>
<lname>singh</lname>
<listofaddress>
<address>

<street>college street</street>
<city>bangalore</city>
<state>karnatka</state>
<datestayed>04-01-2015 - 07-08-2015</datestayed>
</address>
<address>

<street>pakala street</street>
<city>Hyd</city>
</state>
<datestayed>07-10-2015 - 10-08-2017</datestayed>
</address>

<address>
</street>
<city>chennai</city>
<state>TN</state>
<datestayed>10-08-2017</datestayed>
</address>

</listofaddress>

<Comments>
<Comment>
<Mgrcomment>skiled labor</Mgrcomment>
<employeecomment>satisfied work</employeecomment>
<leadcomment>hard worker</leadcomment>
<clientcomment>satisfied work</clientcomment>
<place>bangalore</place>
</Comment>

<Comment>
<Mgrcomment>excellent communications</Mgrcomment>
<employeecomment>hard worker</employeecomment>
<leadcomment>need to improve skill set</leadcomment>
</clientcomment>
<place>bangalore</place>
</Comment>


<Comment>
<Mgrcomment>keep going</Mgrcomment>
</employeecomment>
<leadcomment>keep moving</leadcomment>
</clientcomment>
<place>Hyd</place>
</Comment>
</Comments>
</emp>


expected output xml::::::::::

<emp>
<id>985426</id>
<fname>jai</fname>
<lname>singh</lname>
<listofaddress>
<address>

<street>college street</street>
<city>bangalore</city>
<state>karnatka</state>
<datestayed>04-01-2015 - 07-08-2015</datestayed>
</address>
<address>

<street>pakala street</street>
<city>Hyd</city>
<state>NNNNNNNNNNNNNNNNNNNNN</state>
<datestayed>07-10-2015 - 10-08-2017</datestayed>
</address>

<address>
<street></street>
<city>chennai</city>
<state>TN</state>
<datestayed>10-08-2017</datestayed>
</address>

</listofaddress>

<Comments>
<Comment>
<Mgrcomment>skiled labor</Mgrcomment>
<employeecomment>satisfied work</employeecomment>
<leadcomment>hard worker</leadcomment>
<clientcomment>satisfied work</clientcomment>
<place>bangalore</place>
</Comment>

<Comment>
<Mgrcomment>excellent communications</Mgrcomment>
<employeecomment>hard worker</employeecomment>
<leadcomment>need to improve skill set</leadcomment>
<clientcomment>NNNNNNNNNNNNNNNNNNNNN</clientcomment>
<place>bangalore</place>
</Comment>


<Comment>
<Mgrcomment>keep going</Mgrcomment>
<employeecomment>NNNNNNNNNNNNNNNNNNNNN</employeecomment>
<leadcomment>keep moving</leadcomment>
<clientcomment>NNNNNNNNNNNNNNNNNNNNN</clientcomment>
<place>Hyd</place>
</Comment>
</Comments>
</emp>

RHZ123
Contributor
Contributor

Hi Eric,

 

Ihave this error can you help me please ?

 

0683p000009M1oF.png0683p000009M1oK.png