You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Surendra <su...@hotmail.com> on 2013/06/03 07:20:52 UTC

camel-xmljson

trying a marshall a simple xml to json using xmljson, however json-lib seems
to be returning a JSONArray instead of a JSONObject.  Not sure if it is a
bug?

related entries in camel context

<dataFormats>
	    <xmljson id="xmljsonWithOptions" forceTopLevelObject="false" 
expandableProperties="d e"/>
</dataFormats>

<marshal ref="xmljsonWithOptions"/>


<?xml version="1.0" encoding="UTF-8"?>
<root>
<aps>
<alert>this is a test message</alert>
</aps>
<key3>value3</key3>
<key2>value2</key2>
<key1>value1</key1>
</root>

[#1 - JmsConsumer[test.MyQueue]] XMLSerializer                  INFO  Using
default type string
[#1 - JmsConsumer[test.MyQueue]] route3                         INFO  Got

{"aps":["this is a test
message"],"key3":"value3","key2":"value2","key1":"value1"}




--
View this message in context: http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: camel-xmljson

Posted by Surendra <su...@hotmail.com>.
Thanks Raul.  Saved me ton of time.
Appreciate your help.
Date: Tue, 4 Jun 2013 03:06:33 -0700
From: ml-node+s465427n5733786h15@n5.nabble.com
To: surendrapamidi@hotmail.com
Subject: Re: camel-xmljson



	Hi Surendra,


My tests show that the underlying json-lib is very sensitive to whitespaces

in the input XML.

Removing inter-element whitespaces / XML indentation / pretty-print does

the trick.


So if you marshal this XML into JSON:


<root><aps><alert>this is a test

message</alert></aps><key3>value3</key3><key2>value2</key2><key1>value1</key1></root>


You get:


{"root":{"aps":{"alert":"this is a test

message"},"key3":"value3","key2":"value2","key1":"value1"}}


You can remove XML indentation by running an identity XSLT with xsl:output

indent=no.


Hope that helps,


*Raúl Kripalani*

Enterprise Architect, Open Source Integration specialist, Program

Manager | Apache

Camel Committer

http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk


On Mon, Jun 3, 2013 at 7:33 PM, Surendra <[hidden email]> wrote:


> Thank you.

>

> Date: Mon, 3 Jun 2013 08:53:18 -0700

> From: [hidden email]

> To: [hidden email]

> Subject: Re: camel-xmljson

>

>

>

>         I'll take a look at it later.

>

>

> Regards,

>

>

> *Raúl Kripalani*

>

> Enterprise Architect, Open Source Integration specialist, Program

>

> Manager | Apache

>

> Camel Committer

>

> http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk

>

>

> On Mon, Jun 3, 2013 at 4:02 PM, Surendra <[hidden email]> wrote:

>

>

> > Did anybody came across this issue? any clues?

>

> >

>

> >

>

> >

>

> > --

>

> > View this message in context:

>

> > http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733712.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.

>

> >

>

>

>

>

>

>

>

>

>

>

>

>

>                 If you reply to this email, your message will be added to

> the discussion below:

>

> http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733722.html
>

>

>

>                 To unsubscribe from camel-xmljson, click here.

>

>                 NAML

>

>

>

>

> --

> View this message in context:

> http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733742.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

>



	
	
	
	

	

	
	
		If you reply to this email, your message will be added to the discussion below:
		http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733786.html
	
	
		
		To unsubscribe from camel-xmljson, click here.

		NAML
	 		 	   		  



--
View this message in context: http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733807.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-xmljson

Posted by Raul Kripalani <ra...@evosent.com>.
Hi Surendra,

My tests show that the underlying json-lib is very sensitive to whitespaces
in the input XML.
Removing inter-element whitespaces / XML indentation / pretty-print does
the trick.

So if you marshal this XML into JSON:

<root><aps><alert>this is a test
message</alert></aps><key3>value3</key3><key2>value2</key2><key1>value1</key1></root>

You get:

{"root":{"aps":{"alert":"this is a test
message"},"key3":"value3","key2":"value2","key1":"value1"}}

You can remove XML indentation by running an identity XSLT with xsl:output
indent=no.

Hope that helps,

*Raúl Kripalani*
Enterprise Architect, Open Source Integration specialist, Program
Manager | Apache
Camel Committer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Mon, Jun 3, 2013 at 7:33 PM, Surendra <su...@hotmail.com> wrote:

> Thank you.
>
> Date: Mon, 3 Jun 2013 08:53:18 -0700
> From: ml-node+s465427n5733722h31@n5.nabble.com
> To: surendrapamidi@hotmail.com
> Subject: Re: camel-xmljson
>
>
>
>         I'll take a look at it later.
>
>
> Regards,
>
>
> *Raúl Kripalani*
>
> Enterprise Architect, Open Source Integration specialist, Program
>
> Manager | Apache
>
> Camel Committer
>
> http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk
>
>
> On Mon, Jun 3, 2013 at 4:02 PM, Surendra <[hidden email]> wrote:
>
>
> > Did anybody came across this issue? any clues?
>
> >
>
> >
>
> >
>
> > --
>
> > View this message in context:
>
> > http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733712.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
> >
>
>
>
>
>
>
>
>
>
>
>
>
>                 If you reply to this email, your message will be added to
> the discussion below:
>
> http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733722.html
>
>
>
>                 To unsubscribe from camel-xmljson, click here.
>
>                 NAML
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733742.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

RE: camel-xmljson

Posted by Surendra <su...@hotmail.com>.
Thank you. 

Date: Mon, 3 Jun 2013 08:53:18 -0700
From: ml-node+s465427n5733722h31@n5.nabble.com
To: surendrapamidi@hotmail.com
Subject: Re: camel-xmljson



	I'll take a look at it later.


Regards,


*Raúl Kripalani*

Enterprise Architect, Open Source Integration specialist, Program

Manager | Apache

Camel Committer

http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk


On Mon, Jun 3, 2013 at 4:02 PM, Surendra <[hidden email]> wrote:


> Did anybody came across this issue? any clues?

>

>

>

> --

> View this message in context:

> http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733712.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

>



	
	
	
	

	

	
	
		If you reply to this email, your message will be added to the discussion below:
		http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733722.html
	
	
		
		To unsubscribe from camel-xmljson, click here.

		NAML
	 		 	   		  



--
View this message in context: http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733742.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-xmljson

Posted by Raul Kripalani <ra...@evosent.com>.
I'll take a look at it later.

Regards,

*Raúl Kripalani*
Enterprise Architect, Open Source Integration specialist, Program
Manager | Apache
Camel Committer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Mon, Jun 3, 2013 at 4:02 PM, Surendra <su...@hotmail.com> wrote:

> Did anybody came across this issue? any clues?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733712.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: camel-xmljson

Posted by Surendra <su...@hotmail.com>.
Did anybody came across this issue? any clues?



--
View this message in context: http://camel.465427.n5.nabble.com/camel-xmljson-tp5733645p5733712.html
Sent from the Camel - Users mailing list archive at Nabble.com.