I have a requirement where I have created a Custom Annotation @MaskSensitiveData. I annotate sensitive fields. like
class MyBean {
String userName;
@MaskSensitiveData
String cardNumber;
String abc;
String xyz;
}
ObjectMapper mapper = new ObjectMapper();
String json = null;
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
try {
json = mapper.writeValueAsString(obj);
/*
* if(json != null ) { json = getLoggableString(json); }
*/
} catch (Exception e) {
return "Unable to convert to Json object:" + obj.toString() + " Message: " + e.getMessage();
}I am using Jackson ObjectMapper to convert objct to Json like. I need to customize Object Mapper to mask cardNumber field in return json. Please suggest
--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.