Java FasterXml(Jackson) Mixins and Inheritance -
there 2 simple calsses
public class { private int propid; public int getpropid(){return this.propid;} } public class b extends { }
and 2 mixins
public interface amixin{ @jsonproperty("propida") int getpropid();} public interface bmixin{ @jsonproperty("propidb") int getpropid();} jsonobjectmapper = new objectmapper(); // register mixin jsonobjectmapper.addmixin(b.class, bmixin.class); jsonobjectmapper.addmixin(a.class, amixin.class);
the following 2 calls same results:
jsonobjectmapper.writevalue(writer, new a()); jsonobjectmapper.writevalue(writer, new b());
but expect propida first , propidb second one.
Comments
Post a Comment