Skip to Main Content
Developing Middleware in Java EE 8
book

Developing Middleware in Java EE 8

by Abdalla Mahmoud
June 2018
Intermediate to advanced content levelIntermediate to advanced
252 pages
6h 45m
English
Packt Publishing
Content preview from Developing Middleware in Java EE 8

Returning JSON

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Java EE Development with WildFly

Mastering Java EE Development with WildFly

Luca Stancapiano

Publisher Resources

ISBN: 9781788391078Supplemental Content