Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the JSON format for spring-data-rest

Currently spring-data-rest is returning JSON in HAL format in a spring-boot project of mine. I am using an ember.js frontend and want to use jsonapi (http://jsonapi.org/) specification.

How might I register a new JSON formatting strategy given I will need to write the formatter myself as one does not exists yet?

like image 347
jax Avatar asked Mar 04 '15 00:03

jax


1 Answers

This is how you can customize the HATEOAS that Spring Data REST produces:

https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.customizing-json-output

If you need to completely replace the JSON representation with your own, then you can write and register your own org.springframework.core.convert.converter

Or you write your custom REST endpoints in a plain old @RepositoryRestController and implement your own REST endpoints. (<= I suggest try this)

like image 75
Robert Avatar answered Sep 30 '22 07:09

Robert