java - Jackson mapper to persistence object -
i writing junit complex hierarchy application need test service input large , complicated persistence object. big decided initialize jsonn string. problem because has large inheritance tree getting difficult jackson de serializing it. there why instruct jackson annotation not automatic serializing , explicit. want ignore filed , getters/setters except 1 @jsonproperty annotation
solved using following config
getmapper().setvisibilitychecker(getmapper().getdeserializationconfig().getdefaultvisibilitychecker() .withcreatorvisibility(jsonautodetect.visibility.none) .withfieldvisibility(jsonautodetect.visibility.none) .withgettervisibility(jsonautodetect.visibility.none) .withisgettervisibility(jsonautodetect.visibility.none) .withsettervisibility(jsonautodetect.visibility.none));
Comments
Post a Comment