My userController.java:
@RestController
public class UserController {
private static final Logger LOGGER = LoggerFactory.getLogger
You could use @JsonView
to control what is rendered. You can find more details in this Spring blog post https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring
Assuming you have this View
class with interface Summary
public class View {
interface Summary {}
}
You could then annotate your properties like so:
@JsonView(View.Summary.class)
private String name;
@JsonView(View.Summary.class)
private String firstname;
And then your request mapping:
@JsonView(View.Summary.class)
@RequestMapping(value = "/user", method = RequestMethod.GET)
This would only return name
and firstname
in the resulting JSON.