From the course: Java EE: RESTful Service with JAX-RS 2.0

Unlock the full course today

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

Use JSONP

Use JSONP

From the course: Java EE: RESTful Service with JAX-RS 2.0

Start my 1-month free trial

Use JSONP

- [Narrator] Okay, let's go straight to the book service class and refactor the way we deserialize the list of books we receive from the back end. As you can see, the way we are handling this at the moment is to specify that we want a list of books, and that the response should attempt deserialize this JSON into a list of books. So let's change this, so we can do this operation manually. So the first thing we need to do is to clear the cached book array to ensure that the list of books that we're going to be retrieving is a fresh list of books. So what we need to do, is we need to request that the response is deserialized to a Json array class. We know this is the right type because the response will be a list of books. So we start by writing JsonArray, which we know is going to be the type, and going to call this jsonArray. And as before, I'm simply going to use the response. Now, from the response, I'm going to call the read entity entity method, and parse into the read entity…

Contents