So I need help in using java eclipse collections as part of the response using the spring boot Response Entity JSON . I have tried using the generic way but I get a response exception error that it failed to convert to java ArrayList type so can anyone provide an example for a normal rest endpoint that uses eclipse collections data instead of java collections list?
here is an example code
@GetMapping("/list")
public ResponseEntity<MutableList<Person>> getData() {
return ResponseEntity.ok(Map.of(
"success", true,
"data", Map.of(
"users", personService.getUsers()
)
));
}
Instructions for enabling eclipse-collections Jackson module that adds Json serialization support for Eclipse Collection Types:
By default Spring MVC MappingJackson2HttpMessageConverter will create its own ObjectMapper with default options using Jackson2ObjectMapperBuilder. As per Spring Boot docs 76.3 Customize the Jackson ObjectMapper chapter:
so it should be enough to register eclipse collections module as a bean: