JsonView returning empty json objects
I guess the issue is due to the @ResponceBody ResponseEntity<?>
Please try with the following code :
@JsonView(AuditReportView.Summary.class) @RequestMapping(method = RequestMethod.GET, value = "auditReportSummary" produces = MediaType.APPLICATION_JSON_VALUE) public List<AuditReport getAuditReportSummary() { final List<AuditReport> auditReports = auditDAO.getAuditReportSummary(); return auditReports; }
I am not much sure about it, but you can try if it works..
Try adding a default constructor - ex:
public AuditReport() {}
The default constructor is generated by the java compiler if no custom constructor is specified in the code. However if a custom constructor is specified, the default constructor is no longer automatically added which can break serialization libraries / spring, etc..
BUT - you haven't specified a constructor - how could this be?
One thing I noticed is that you're using Lombok - due to the Data annotation. Lombok can generate constructors for classes. So its possible one of the annotations or libraries you're using is adding a constructor, making the compiler skip generation of a default constructor, which may be breaking your serialization.
So, I hope adding a default constructor works out for you.