I am creating an API by using spring boot. In this project, I used spring web, JPA, jstl and MySql as dependencies of the API. In this project, I have created a Controller,
You could customise the JSON representation of the entity in the Controller by using Spring's support for Jackson's JSONView.
https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring#json-views
@JsonView(View.Summary.class)
@GetMapping("/developers/{id}")
public ImModel findByName(@PathVariable final int id){
return TaskRepository.findById(id);
}
Alternatively, you could handle at the repository level by using Spring Data's projection functionality:
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections
@GetMapping("/developers/{id}")
public ImModelSummaryProjection findByName(@PathVariable final int id){
return TaskRepository.someMethodReturningSummaryProjection(id);
}