From the course: JSON Processing with Java EE

Unlock the full course today

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

Output the JSON model to a data stream

Output the JSON model to a data stream

From the course: JSON Processing with Java EE

Start my 1-month free trial

Output the JSON model to a data stream

- [Narrator] Regardless of how the Json object was created, you're going to want to do something with it. Whether that be persisting it to a database, extracting and processing elements of data from it, or simply passing it on to the final consumer. One thing you can do is to output it to a stream so that it can be persisted or shared with another system. In this video, we will discuss ways that you can output the Json object to a stream. At the beginning of this chapter, we saw how to use the Json Reader to load Json data into memory in the form of a Json object. Now we're going to use the Json Writer to flatten this object to a string. We do this by creating an instance of the Json Writer, by calling a factory method in the Json class. We then parse it either an instance of the Writer object, or an OutputStream object from the Json.io package. Okay, so let's switch to the IDE and see how to do this. Okay, so let's load up the object example six class from the exercise files. In this…

Contents