camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reji Mathews <contactr...@gmail.com>
Subject Re: Handle white space - JSON to XML using XMLJSON component
Date Wed, 13 May 2015 07:52:49 GMT
Hi Guru

I really wonder if XML element name supports white spaces and if its
legal.. If not, it shudn't be for json either.

Anything which comes with a space might be interpreted as XML attribute.

Think this way! What will a classname look like when it gets converted to
equivalent java classes :-)

Cheers
Reji


On Wed, May 13, 2015 at 12:39 PM, Gnanaguru S <gnanagurus@gmail.com> wrote:

> Hi Guys,
>
> I recently got impressed with xmljson component, it does pretty good job in
> transforming JSON to XML and vice versa.
>
> I have a JSON payload which has keys with white space, xmljson doesnt
> accept
> JSON keys with whitespaces and it throws the exception shown below.
>
> This is my JSON payload:
>
> {
>   "Format": "JSON",
>   "TestData": {
>    * "Key with Spaces in it"*: {
>       "And Again": {
>         "ChildKey1": "Financial",
>         "ChildKey2": null
>       },
> .........
> .....
>
> Is there a camel way to handle this ? Or I have to write a processor to
> remove white spaces only on the keys ?
>
> nu.xom.IllegalNameException: 0x20 is not a legal NCName character
>         at nu.xom.Verifier.throwIllegalNameException(Unknown Source)
>         at nu.xom.Verifier.checkNCName(Unknown Source)
>         at nu.xom.Element._setLocalName(Unknown Source)
>         at nu.xom.Element.<init>(Unknown Source)
>         at nu.xom.Element.<init>(Unknown Source)
>         at net.sf.json.xml.XMLSerializer.newElement(XMLSerializer.java:869)
>         at
> net.sf.json.xml.XMLSerializer.processJSONObject(XMLSerializer.java:989)
>         at
> net.sf.json.xml.XMLSerializer.processJSONValue(XMLSerializer.java:1040)
>         at
> net.sf.json.xml.XMLSerializer.processJSONObject(XMLSerializer.java:990)
>         at net.sf.json.xml.XMLSerializer.write(XMLSerializer.java:605)
>         at net.sf.json.xml.XMLSerializer.write(XMLSerializer.java:570)
>         at
>
> org.apache.camel.dataformat.xmljson.XmlJsonDataFormat.convertToXMLUsingEncoding(XmlJsonDataFormat.java:191)
>         at
>
> org.apache.camel.dataformat.xmljson.XmlJsonDataFormat.unmarshal(XmlJsonDataFormat.java:186)
>         at
>
> org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:65)
>         at
>
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
>         at
> org.apache.camel.processor.interceptor.Debug$1.process(Debug.java:50)
>         at
>
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
>         at
>
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
>         at
>
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
>
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
>         at
>
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
>         at
>
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
>         at
>
> org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:73)
>         at
> org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:378)
>         at
> org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:346)
>         at
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:242)
>         at
> org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:346)
>         at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:201)
>         at
>
> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
>         at
>
> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
>         at
>
> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:149)
>         at
>
> org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:297)
>         at
>
> Regards
> Guru
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Handle-white-space-JSON-to-XML-using-XMLJSON-component-tp5767042.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message