camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From RudyVonWald <michael.vonw...@hpe.com>
Subject camel-xmljson
Date Thu, 23 Jun 2016 21:13:25 GMT
I have an issue where I am using xmljson in a Camel route. 
I have some XML input where sometimes the content can contain multiple
elements but can also just contain a single element.

    <Country OU="CA">
        <DocumentType>
            <Code>15</Code>
            <UploadReportCount>30</UploadReportCount>
        </DocumentType>
    </Country>

OR

<Country OU="CA">
        <DocumentType>
            <Code>4</Code>
            <UploadReportCount>1238</UploadReportCount>
        </DocumentType>
        <DocumentType>
            <Code>6</Code>
            <UploadReportCount>1240</UploadReportCount>
        </DocumentType>
</Country>


xmljson converts this to JSON fine, but give two different results depending
on how many elements are there.

{"Country":{"OU":"CA","DocumentType":{"Code":"15","UploadReportCount":"30"}}}

{"Country":{"OU":"CA","DocumentType":[{"Code":"4","UploadReportCount":"1238"},{"Code":"6","UploadReportCount":"1240"}]}}

So my question is, is there a "force-array" setting of some kind or
alternate approach where the results of the transformation will result in a
single element array for a chosen element?

i.e. 
{"Country":{"OU":"CA","DocumentType":[{"Code":"15","UploadReportCount":"30"}]}}

I need the output to be consistent for the DocumentType level.

Thanks





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

Mime
View raw message