Java XStream - Ignore tag that doesn't exist in XML

前端 未结 6 813
小蘑菇
小蘑菇 2020-12-28 21:26

I currently use a piece of XML like the following


    Frank Smith
    100023412
    1         


        
6条回答
  •  别那么骄傲
    2020-12-28 21:39

    From the x-stream FAQ:

    How does XStream deal with newer versions of classes?

    • If a new field is added to the class, deserializing an old version will leave the field uninitialized.
    • If a field is removed from the class, deserializing an old version that contains the field will cause an exception. Leaving the field in place but declaring it as transient will avoid the exception, but XStream will not try to deserialize it.
    • ...
    • implement a custom mapper to ignore unknown fields automatically (see acceptance test CustomMapperTest.testCanBeUsedToOmitUnexpectedElements())

提交回复
热议问题