REST Web Services – HAL Format for JSON

I didn’t know about this, that there is a ‘format’ – a certain way of building/composing your REST API, especially when you have to expose a Tree structure in the JSON

https://dzone.com/articles/introduction-hypertext-0

https://spring.io/guides/gs/accessing-neo4j-data-rest/

Spring Data REST uses the HAL format for JSON output. It is flexible and offers a convenient way to supply links adjacent to the data that is served.

http://stateless.co/hal_specification.html


5.1.3. Resource Discoverability
A core principle of HATEOAS is that resources should be discoverable through the publication of links that point to the available resources. There are a few competing de-facto standards of how to represent links in JSON. By default, Spring Data REST uses HAL to render responses.


What’s interesting about this project is that in the Spring ecosystem there is another project which is called ‘Spring Data Rest’ and that is a broader approach. That is a more comprehensive solution which makes a lot of assumptions. For example, one of those assumptions is not using JSON but using HAL as a media format and that is not what Spring HATEOAS does. What Spring HATEOAS really does, is that it gives us some extra tools essentially to build out links and hypermedia information inside our responses and that’s about it.

Leave a comment