I want to create an annotation so that Jackson ignores annotated fields if a specific trace level is not set:
public class A { @IgnoreLevel("Debug") String str1; @IgnoreLevel("Info") String str2; }
Or, if this is easier to implement, I can also have separate annotations for different levels:
public class A { @Debug String str1; @Info String str2; }
Depending on the configuration of ObjectMapper , either
- all Debug and Info fields should be ignored during serialization and deserialization, or
- all Debug fields must be ignored, or
- All fields must be serialized / deserialized.
I believe this should be possible with a custom AnnotationIntrospector . I have this post , but it does not show an example of how to implement a custom AnnotationIntrospector .
source share