A RESTful web service using JSON-B

In the previous section, we implemented the RESTful web service using JAXB. As mentioned earlier, JEE 8 has added a new specification for JSON binding, called JSON-B. In this section, we will learn how to modify our web service to use JSON-B. 

There is really not much that we need to change in the code to switch from JAXB to JSON-B. We will need to use the @JsonbProperty annotation of JSON-B to specify field binding in the Course class, instead of the @XmlAttribute annotation of JAXB. Then, we will need to add Maven dependencies to include libraries that provide JSON-B APIs and its implementations. Replace the dependencies section in pom.xml with the following: 

  <dependencies>   <dependency>    <groupId

Get Java EE 8 Development with Eclipse 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.