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.
Streaming generator - Java EE Tutorial
From the course: Java EE 8 Essential Training
Streaming generator
- [Narrator] The JSON processing API features a JSON generator as part of the streaming API. It can be used to write JSON objects to an output source in a streaming way. Let's take a look as we work within our order resource to use our JSON generator to build a new JSON object. So I'm going to remove all pre-existing code within this method and then what we'll do is build a streamlined order object that is generated using the JSON generator. Now there's better ways to do this, but it does give us a good experience working with the JSON generator so that we can see a lot of its features in action. Now when we work with the JSON generator, the first thing we need to do is have some sort of output source. In our case, that's going to be a string writer. So I'm going to go ahead and create a new string writer and then we can start to build our JSON generator. So we'll create an object of type JSON generator and I'm just going…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.