Let's try to return our first JSON object with JAX-RS. It is so easy that you don't need to handle any special stuff yourself, just return your object from a method declared to return JSON's media type using the @Produces annotation, nothing more!
In the following example, we are going to simulate an in-memory database of movies using a HashMap. We are going to create a map of movies, where the key is the movie's id (primary key), and the value is an object representing a movie in some database. We will support two operations in this example:
- Retrieving a movie by id
- Listing all movies found in our database
Before we go on with this example, let's discuss how we should design our RESTful services. The dominant convention ...