Seamlessly converting between Java and JSON
RESTful web services transfer data in plain text, typically, but this is not limited to JSON-formatted data. In our examples so far, we have been sending and receiving JSON strings between our RESTful services and their clients.
Frequently, we would like to populate Java objects from the JSON data we receive, manipulate the data somehow, and then build a JSON string to send as a response. The population of Java objects from JSON, and the generation of JSON data from Java objects, is so common that the Jakarta REST implementation provides a way to do it seamlessly and automatically.
In previous examples in this chapter, we have been sending and receiving raw JSON data as strings. Our sample data contains customer information such as first name, middle name, and last name. To make this data easier to manipulate, we would typically populate a Java object with this data; for example, we could parse the JSON data and populate an instance...