Thanks Raul for your promptly reply. 
I configured the xmljson in the <dataFormats> as instructed online document : 
Apache Camel: XmlJson
|   |
|   |   |   |   |   |
| Apache Camel: XmlJsonXML JSON Data Format (camel-xmljson) Available as of 
Camel 2.10  |
|  |
| View on camel.apache.org | Preview by Yahoo |
|  |
|   |

For example,
 <dataFormats> <xmljson id="xml2json" forceTopLevelObject="true" 
skipWhitespace="false" trimSpaces="false" skipNamespaces="true" 
removeNamespacePrefixes="true" /> <xmljson id="json2xml" rootName="MX"  
expandableProperties="" elementName="" arrayName="" /> </dataFormats>
And we use the marshal below to reference above: 
 <marshal ref="xml2json" />

We use the Spring configuration only to configure the routes.
Could you advise how we can test the scenario you suggested?
Have you changed any defaults of the xmljson data format? >>>>> noCould you try 
calling your attribute json_type, or switching to the TypeHintsEnum.WITH_PREFIX 
value for thetypeHints option?
>>>>> Could you give an example how I can test above two scenarios? Namely: 1) 
>>>>> calling your attribute json_type;2)  switching to the 
>>>>> TypeHintsEnum.WITH_PREFIX value for the typeHints option?
Thanks much
 

    On Thursday, January 7, 2016 11:59 AM, Raul Kripalani <ra...@apache.org> 
wrote:
 

 Hi,
Have you changed any defaults of the xmljson data format? By default it comes 
with type hints enabled with type hints compatibility = true.
I'm looking at the jsonlib docs and it seems contradictory with the value of 
type hints compatibility. Could you try calling your attribute json_type, or 
switching to the TypeHintsEnum.WITH_PREFIX value for the typeHints option?
Cheers,
Raúl KripalaniPMC & Committer @ Apache Ignite, Apache Camel | Integration, Big 
Data and Messaging Engineerhttp://about.me/raulkripalani http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk
On Thu, Jan 7, 2016 at 4:38 PM, Jack Ding <hding...@yahoo.com.invalid> wrote:

Hello,
I am trying to do the XML to JSON conversion using camel-xmljson with some 
specified date types such as number, boolean, etc. 
Example 1: input XML:<a>  <b>string</b>

  <c>12345</c></a>


Expected JSON:
{"a":{"b":"string", "c": 12345}}
You can see 12345 should be a number instead of a string.  

Result JSON:{"a":{"b":"string", "c": "12345"}}

Notice the double quotes around the 12345.
Example 2: In this example we specify the type="number" . input XML:<a>  
<b>string</b>

  <ctype="number">12345</c></a>


Expected JSON:
{"a":{"b":"string", "c": 12345}}
You can see 12345 should be a number instead of a string.  

Result JSON:{"a":{"b":"string", "c": {"@type":"number","#text":"12345"}}}

We are using the spring XML to configure the camel routes and data format.
Could anybody give some advise if there is a easier way to configure above in 
Spring XML wihtout involving customized java code? 
Thanks




  

Reply via email to