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
From the course: JSON Processing with Java EE
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…
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.
Contents
-
-
-
-
-
(Locked)
Introduction to the object model2m 44s
-
(Locked)
Create a model from a JSON string6m 48s
-
(Locked)
Create a model from a JSON file2m 48s
-
(Locked)
JSON builder API1m 24s
-
Build a JSON model8m 30s
-
(Locked)
How to traverse the model1m 36s
-
(Locked)
Traverse the JSON model6m 19s
-
(Locked)
Output the JSON model to a data stream3m 16s
-
(Locked)
Challenge: JSON array object30s
-
(Locked)
Solution: JSON array object1m 11s
-
(Locked)
Challenge: Write unit test27s
-
(Locked)
Solution: Write unit test23s
-
(Locked)
Challenge: Output JSON object to a file18s
-
(Locked)
Solution: Output JSON object to a file36s
-
(Locked)
-
-