You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by ganges_k <ga...@yahoo.com> on 2010/09/13 14:22:47 UTC

XML to JSON conversion

Hi,

I am using Camel-SNMP in one of our requirement. Camel-SNMP process the
OID's and provide XML as the output. I want to convert this to JSON format.
is there a way to convert the output XML to JSON format?


Thanks in advance.

Best Regards,
Gangadhar.Katakam
-- 
View this message in context: http://camel.465427.n5.nabble.com/XML-to-JSON-conversion-tp2837615p2837615.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: XML to JSON conversion

Posted by ganges_k <ga...@yahoo.com>.
Thank you for the reply.
I am sorry to bother you. 

I have searched in the camel users group and found the solution.
-- 
View this message in context: http://camel.465427.n5.nabble.com/XML-to-JSON-conversion-tp2837615p2849256.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: XML to JSON conversion

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Sep 16, 2010 at 6:31 AM, ganges_k <ga...@yahoo.com> wrote:
>
> Thank you for the reply.
>
> I am trying to unmarshalling the xml format to java object but i am getting
> the following error.
>
> Caused by: javax.xml.bind.JAXBException: "com.example.SNMPPojo.class" doesnt
> contain ObjectFactory.class or jaxb.index
>
> can you please let me know how to resolve this?
> --

This is standard JAXB so go google and read about how to work with JAXB.
For example googling the exception most likely will give you some good
links to follow and read.


> View this message in context: http://camel.465427.n5.nabble.com/XML-to-JSON-conversion-tp2837615p2841723.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: XML to JSON conversion

Posted by ganges_k <ga...@yahoo.com>.
Thank you for the reply.

I am trying to unmarshalling the xml format to java object but i am getting
the following error.

Caused by: javax.xml.bind.JAXBException: "com.example.SNMPPojo.class" doesnt
contain ObjectFactory.class or jaxb.index

can you please let me know how to resolve this?
-- 
View this message in context: http://camel.465427.n5.nabble.com/XML-to-JSON-conversion-tp2837615p2841723.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: XML to JSON conversion

Posted by Willem Jiang <wi...@gmail.com>.
On 9/14/10 3:49 PM, ganges_k wrote:
>
> Thanks for the reply.
>
> If i convert xml ->  java object ->  json (format), will there be any
> performance impact?
> I am looking for a direct conversion in Camel. does Camel provide this kind
> of feature?
>
>
No, current camel provides this kind of feature out of box.
But you do it yourself, and you can use Camel DataFormat API to let 
Camel use your implementation.

Willem

Re: XML to JSON conversion

Posted by ganges_k <ga...@yahoo.com>.
Thanks for the reply.

If i convert xml -> java object -> json (format), will there be any
performance impact?
I am looking for a direct conversion in Camel. does Camel provide this kind
of feature?


-- 
View this message in context: http://camel.465427.n5.nabble.com/XML-to-JSON-conversion-tp2837615p2838750.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: XML to JSON conversion

Posted by Willem Jiang <wi...@gmail.com>.
On 9/13/10 8:22 PM, ganges_k wrote:
>
> Hi,
>
> I am using Camel-SNMP in one of our requirement. Camel-SNMP process the
> OID's and provide XML as the output. I want to convert this to JSON format.
> is there a way to convert the output XML to JSON format?
>
You can convert the XML to Java Object then turn it into JSON.
Camel DataFormat[1] supports this kind of conversion.

If you have time, you can consider to write a customer code by using the 
XStream[1], as it support XML and JSON out of box.
>
> Thanks in advance.
>
> Best Regards,
> Gangadhar.Katakam

[1]http://camel.apache.org/data-format.html
[2]http://xstream.codehaus.org/

Willem