Jackson JSON : Subclass fields not seralized if implements java.util.Set -


i have following inheritance

interface resultset extends java.util.set<customresult> {     public int getcount(); }  @xmlaccessortype(xmlaccesstype.none) @xmltype(name = "customresultset") class customresultset extends linkedhashset<customresult> implements resultset {      @xmlelement(name = "count")     private int count;      public void setcount(int count) {        this.count = count     }  } . . public static void main() { objectmapper objectmapper = new objectmapper(); objectmapper.disable(deserializationfeature.fail_on_unknown_properties); objectmapper.disable(serializationfeature.fail_on_empty_beans); customresultset customresultset = new customresultset(); customresult customresult = new customresult(55, "abc"); customresultset.setcount(11); customresultset.add(customresult); system.out.println(objectmapper.writevalueasstring(customresultset));  } 

with above code serializes values in collection customresultset not field count in customresultset .

anything implements set interface treated set jackson , result in json array, if put annotations on custom class. best shot have custom serializer class.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -