java - Jackson custom type info not working -


i've got classes use @jsontypeidresolver add custom type field output. code working expected. i've added propertyfilter mapper object. @jsontypeidresolver stopped working. factory not being called anymore.

working code:

objectmapper mapper = new objectmapper(); mapper.writevalue(outputstream,myobject); 

not working code:

objectmapper mapper = new objectmapper(); propertyfilter myfilter=new simplebeanfilter() {    protected boolean include(beanpropertywriter writer) {       return true;    }    protected boolean include(propertywriter writer) {       return true;    } } filterprovider filters=new simplefilterprovider().addfilter("myfilter",myfilter); mapper.writer(filter).writevalue(outputstream,myobject); 

as filter useless (accepts anything) output should same. why type field not serialized anymore?

seems jackson doesn't deal inheritance right way. test setup like

 @jsontypeinfo( use = jsontypeinfo.id.class, include = as.property, property = "_type" )  abstract class base {      string somefield;      ...  }   class childa extends base {      ...  }   class childb extends base {      ...  } 

if write custom serializer, explicitely casts childa , childb base before serializing, works expected. basic issue jackson not recognize annotations on parent objects, if not explicitly told so.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -