Hi

Had the same issue some time ago. 
I think the resulting json should be an array in both cases since the xml
Value element is 0-n.
In your first example the resulting json will be a jsonobject, and it should
have been an array.

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

example 2 :

{ 
        "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" 
        }] 
} 

The problem is that xmltojson is not able from the xml to determine if it
should generate an json object or an array thats why you get 2 different
outputs.

As i recall we ended up with an pojo afterburner on the generated json
converting the jsonobject to an array if needed.

Since then I stumbled on this thread
http://stackoverflow.com/questions/34053941/xml-to-json-single-valued-array-handling?rq=1

Maybe that might be of help. Havn't had the time to try it out myself.

/Preben 



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

Reply via email to