Hello All,

I am using 'xmljson' to convert a simple XMl to JSON, but looks like its not
working properly, Below what I am doing
 <dataFormats>
                <xmljson id="jsonRequestXml" />
 </dataFormats>

<route id="test" autoStartup="true">
   <from uri="restlet:/test?restletMethods=GET"/>
   <to uri="bean:testBean?method=returnXml"/> 
   <log message="XML: ${body}"/> 
   <marshal ref="jsonRequestXml"/>
   <log message="JSON: ${body}"/> 
</route>


Xml Input: 
<Response>
        <Version>2.0</Version>
        <ErrorCode>0</ErrorCode>
        <ErrorMsg>OK</ErrorMsg>
        <Value>
                <InstallKey>
                        <CustomerProductId>5957152</CustomerProductId>
                        <KeyPoolName>Standard_EMEA</KeyPoolName>
                        <ProductId>37293</ProductId>
                        <Value>ABCD-EFGH-CC-89</Value>
                </InstallKey>
        </Value>
</Response>

Json Outpout: 

 {
        "Version": "2.0",
        "ErrorCode": "0",
        "ErrorMsg": "OK",
        "Value": {
                "InstallKey": {
                        "CustomerProductId": "5957152",
                        "KeyPoolName": "Standard_EMEA",
                        "ProductId": "37293",
                        "Value": "ABCD-EFGH-CC-89"
                }
        }
 }

So there is no problem, and i am happy with above.

But problem happening with when there is an array Please look below 

Input XML: 
<Response>
        <Version>2.0</Version>
        <ErrorCode>0</ErrorCode>
        <ErrorMsg>OK</ErrorMsg>
        <Value>
                <InstallKey>
                        <CustomerProductId>5957152</CustomerProductId>
                        <KeyPoolName>Standard_EMEA</KeyPoolName>
                        <ProductId>37293</ProductId>
                        <Value>ABCD-EFGH-CC-87</Value>
                </InstallKey>
                <InstallKey>
                        <CustomerProductId>5957152</CustomerProductId>
                        <KeyPoolName>Standard_EMEA</KeyPoolName>
                        <ProductId>37293</ProductId>
                        <Value>ABCD-EFGH-CC-89</Value>
                </InstallKey>
        </Value>
</Response>

Output Json: 

{
        "Version": "2.0",
        "ErrorCode": "0",
        "ErrorMsg": "OK",
        "Value": [{
                "CustomerProductId": "5957152",
                "KeyPoolName": "Standard_EMEA",
                "ProductId": "37293",
                "Value": "ABCD-EFGH-CC-87"
        }, {
                "CustomerProductId": "5957152",
                "KeyPoolName": "Standard_EMEA",
                "ProductId": "37293",
                "Value": "ABCD-EFGH-CC-89"
        }]
}

As you can see 'InstallKey' element is missing but its value added as an
array, :( 

Should not the output be like below 

{
        "Version": "2.0",
        "ErrorCode": "0",
        "ErrorMsg": "OK",
        "Value": {"InstallKey": [{
                "CustomerProductId": "5957152",
                "KeyPoolName": "Standard_EMEA",
                "ProductId": "37293",
                "Value": "ABCD-EFGH-CC-87"
        }, {
                "CustomerProductId": "5957152",
                "KeyPoolName": "Standard_EMEA",
                "ProductId": "37293",
                "Value": "ABCD-EFGH-CC-89"
        }]}
}


I am kind tried everything but no hope and cant figure out whether i am
doing something wrong or its a bug with 'xmljson'



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-xmlJson-not-working-properly-tp5795193.html
Sent from the Camel Development mailing list archive at Nabble.com.

Reply via email to