I want to create an annotation to make Jackson ignore the annotated fields unless a certain tracing level is set:
public class A {
@IgnoreLevel("Debug") String str1;
@IgnoreLevel("Info") String str2;
}
Or, if this is easier to implement, I could also have separate annotations for the different levels:
public class A {
@Debug String str1;
@Info String str2;
}
Depending on the configuration of the ObjectMapper
, either
- all "Debug" and "Info" fields shall be ignored when serializing and deserializing, or
- all "Debug" fields shall be ignored, or
- all fields shall be serialized/deserialized.
I suppose that this should be possible with a custom AnnotationIntrospector
. I have this post, but it doesn't show an example of how to implement a custom AnnotationIntrospector
.