marshallingjsonix

Jsonix Element and value restriction


I am using JSONIX to marshall and unmarshall XML received from other system. The XML I want to marshall and unmarshall

<charge> 392.2361
<formatted>392.24</formatted>
</charge>

I still cannot figure out how to unmarshall the value "392.2361". Any one with any idea? Thanks in advance


Solution

  • What you need here is a mixed property.

    {
        type: 'classInfo',
        localName: 'MyType',
        propertyInfos: [{
            type: 'elementRef',
            name: 'charge',
            elementName: 'formatted',
            collection : true,
            mixed: true
        }]
    }
    

    What you'll as value get is something like:

    [ '392.2361', { name: { localPart: 'formatted' }, value: '392.24' }]
    

    Not tested, no guarantees but you get the idea.