shawnuser3862921
shawnuser3862921

Reputation: 127

How to make JSONIX tolerate extra XML elements on deserialization?

I'm using JSONIX 2.0.12 and it's awesome.

I have a large XML file for which I only care to deserialize a subset of elements to JSON.

When I leave some elements out of my mapping file, jsonix complains with an unexpected element error when deserializing.

Is there a way to have jsonix only pay attention to elements declared in my mapping and ignore the rest of the xml?

Upvotes: 0

Views: 161

Answers (1)

lexicore
lexicore

Reputation: 43671

Jsonix author here. Thank you for your feedback. :)

Please file an issue here, this is a reasonable request, I'll implement this.

Right now you can work around this by adding an any element property:

{
    type: 'classInfo',
    localName: 'MyType',
    propertyInfos: [{
        type: 'anyElement',
        name: 'catchAll',
        collection: true
    }]
}

This property will get all the "unknown" elements. This is not exactly what you want as the elements are not ignored and you have to add this property everywhere. Just a workaround. Please file an issue, I'll get it done in 2.1.1.

BTW, 2.1.0 was released few weeks ago.

Update

This is fixed in 2.1.1 (yet to be released).

Upvotes: 1

Related Questions