Chapter 4. Data Representation

We looked at how to build a RESTful endpoint in the previous chapter. We also briefly discussed how the data is represented in REST responses. In this chapter, we will expand on these discussions and cover the following topics:

  • The Data-Transfer-Object design pattern
  • Controlling the responses format in JSON
  • Tips on formatting responses
  • API evolutions

Before we delve into the specifics of how to control our JSON responses, let's first take a look at the DTO design pattern.

The Data-Transfer-Object design pattern

A data transfer object is a simple wrapper around properties, which is passed between layers of an application. This pattern offers a good abstraction level between how the data is stored and managed internally and ...

Get Building a RESTful Web Service with Spring now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.