java - Jackson JSON mapping of superclass value -



java - Jackson JSON mapping of superclass value -

i using jackson 1.8.3 in spring application map java objects json.

one of java class (child) extends super class (parent) part of libary, not able modify it. (especially not able add together annotations.)

i using @jsonautodetect(jsonmethod.none) because need little set of fields object, instead using @jsonproperty.

class parent { public long getid(){...}; ... } @jsonautodetect(jsonmethod.none) class kid extends parent { @jsonproperty private string title; }

but 1 of fields need field id superclass, don't know how tell jackson pay attending field, without modifying parent class (because can not modify it).

i not able add together annotations

you can add together annotations using mix-ins. see http://wiki.fasterxml.com/jacksonmixinannotations details.

depending on rest of class feild/method structures are, approach might work configure visibility access of fields/methods through objectmapper. next line demonstrates how create such configuration, not specific configuration need.

mapper.setvisibilitychecker(mapper.getvisibilitychecker().withfieldvisibility(visibility.any));

i using @jsonautodetect(jsonmethod.none) because need little set of fields object, instead using @jsonproperty

i should have realized possible. have update blog post. give thanks you.

java json spring jackson

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -