🚀 Master the language of AI with our brand new course: "Prompt Engineering for Everyone" Learn more

Offered By: IBM

Consuming a RESTful Java web service using JSON-B and JSON-P

Explore how to access a simple RESTful web service and consume its resources in Java using JSON-B and JSON-P.

Continue reading

Guided Project

Open Liberty

228 Enrolled
4.7
(41 Reviews)

At a Glance

Explore how to access a simple RESTful web service and consume its resources in Java using JSON-B and JSON-P.

You will learn how to access a REST service, serialize a Java object that contains a list of artists and their albums, and use two different approaches to deserialize the returned JSON resources. The first approach consists of using the Java API for JSON Binding (JSON-B) to directly convert JSON messages into Java objects. The second approach consists of using the Java API for JSON Processing (JSON-P) to process the JSON.

The REST service that provides the artists and albums resources is already written for you. When the server is running, this service is accessible at the http://localhost:9080/artists endpoint, which responds with the artists.json file.

You will implement the following two endpoints using the two deserialization approaches:
  • …​/artists/total to return the total number of artists in the JSON
  • …​/artists/total/<artist> to return the total number of albums in the JSON for the particular artist
If you are interested in learning more about REST services and how you can write them, read Creating a RESTful web service.

Created by 

The Open Liberty Project team

Estimated Effort

1 Hour

Level

Beginner

Skills You Will Learn

Java

Language

English

Course Code

GPXX0M7ZEN

Tell Your Friends!

Saved this page to your clipboard!

Sign up to our newsletter

Stay connected with the latest industry news and knowledge!