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.

JSON-B configuration

JSON-B configuration - Java EE Tutorial

From the course: Java EE 8 Essential Training

Start my 1-month free trial

JSON-B configuration

- [Instructor] In this lesson, we're going to take a look at how we can provide configuration to JSON-B to control its behavior when it's serializing and deserializing from JSON to Java. So, we're going to get started within the order endpoint. And what we're going to do is use the JsonbConfig object and we'll just call it config, and there's the new operator and the constructor to create this object. And now we have a configuration object that we can use to provide all sorts of configuration to JSON-B regarding how we would like it to behave. So, you can see quite a few configurations here that we can set, we're just going to go ahead and set the with formatting option, and we'll set that to true, and that's going to cause it to pretty-print our JSON. So, we will get some new lines in there and it will be easier to read. And then all we need to do is pass that configuration into our JSON builders create method. And it…

Contents