Hi George,

George.Francis wrote:

> 
> I have some code that is deserializing an object from some JSON text:
> 
> Level level = (Level) xstream.fromXML( levelJson );
> 
> it's throwing an exception because the Levels in levelJson contain an
> attribute 'foo' whereas the Level class has no foo member.
> 
> Is there a way to configure this process to ignore any attributes on
> objects in the JSON that don't exist in the deserializing class?

You can call XStream.omitField for individual elements or you may ignore 
anything unknown writing a custom mapper - see acceptance test 
CustomMapperTest.testCanBeUsedToOmitUnexpectedElements() in 
https://fisheye.codehaus.org/browse/xstream/trunk/xstream/src/test/com/thoughtworks/acceptance/CustomMapperTest.java?r=HEAD

Backdraw is that implicit collections no longer work with this change. Good 
news: Such collections do not work with JSON anyway ;-)

Cheers,
Jörg




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to