Chose ignored files at runtime without use @JsonIgnore

8 views
Skip to first unread message

Victor Costa

unread,
Feb 19, 2020, 4:44:11 PM2/19/20
to jackson-user
Hey, There.

I'd like to know if there a way to choose the fields into an object to be ignored at runtime without using @JsonIgnore anotation on my Model I'm doing the follow code:


mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {
     @Override
     protected boolean _isIgnorable(Annotated a) {
        if( a.getName().contains("foo")) {
         return true;
         }
     };
});

is there any way to do that? 

Tatu Saloranta

unread,
Feb 19, 2020, 4:49:35 PM2/19/20
to jackson-user
There are multiple mechanisms for filtering out properties to write
(serialize), see f.ex:

http://www.cowtowncoder.com/blog/archives/2011/02/entry_443.html

in particular "JSON View"s (annotated sets of fields to include) and
"JSON Filter".

-+ Tatu +-
Reply all
Reply to author
Forward
0 new messages