I have a Java class ( MyResponse ) that is returned by several RestController methods and has many fields.
@RequestMapping(value = "offering", method=RequestMethod.POST) public ResponseEntity<MyResponse> postOffering(...) {} @RequestMapping(value = "someOtherMethod", method=RequestMethod.POST) public ResponseEntity<MyResponse> someOtherMethod(...) {}
I want to ignore (for example, not serialize) one of the properties for only one method.
I do not want to ignore null fields for the class, because this can have a side effect for other fields.
@JsonInclude(Include.NON_NULL) public class MyResponse { ... }
JsonView looks good, but as I understand it, I have to comment out all the other fields in the class using @JsonView except the one I want to ignore, which sounds awkward. If there is a way to do something like "reverse JsonView", that would be great.
Any ideas on how to ignore a property for a controller method?
source share