From the course: Java EE 8 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Object model reader

Object model reader - Java EE Tutorial

From the course: Java EE 8 Essential Training

Start my 1-month free trial

Object model reader

- [Narrator] JSON-P features an object model API that allows us to perform various operations for the JSON data type within Java. Using the object model API, we can create, read, and string JSON objects and array structures using its interface which follows a builder pattern. Let's take a look at how we can read JSON using the object model approach. Within our JAX-RS order resource, we've already written some JSON to a string. We're now going to go ahead and read that using JSON-P's object model. So to get started, we're going to create a JSON reader and the JSON reader implements the auto-closable interface so we're going to create it within a try block. To create a JSON reader, we simply use the JSON object and the create reader method to read an input stream and we're going to use a string reader in order to read the JSON string that we created. So let's go ahead, we'll import those types and now we have our JSON reader…

Contents