Reputation: 1745
I have the following Spring Controller Declaration
@RequestMapping(value = "/pub/searchparm", method = RequestMethod.GET, produces = {"application/json", "application/xml" })
public SearchResult search(HttpServletRequest request) {
public class SearchResult {
private int size;
private Collection<result> results;
...
}
I need to make Jackson default to ignore all the properties on the objects in the Collection by default just for this controller method.
I have looked at @JsonView, @JsonFilter... etc. Jackson includes all properties from the object by default but I have sensitive information that I want to expose only from secure urls. This url is public and I only want some of the properties exposed.
Upvotes: 1
Views: 369
Reputation: 59076
You can use Jackson @JsonView
support in Spring MVC.
Note that Spring MVC support chose to set MapperFeature.DEFAULT_VIEW_INCLUSION
, so that only @JsonView
annotated attributes are serialized.
See this blog post on Jackson support in Spring MVC.
Upvotes: 1