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.
JSON builder API
- [Instructor] We have seen that adjacent structure can be built from adjacent document in a string of that file. What we're going to see now is how to build adjacent structure using the static builder provided by the jsonx.json.jsonclass. This class provides factory methods to create two types of builders, a JsonObjectBuilder which builds Json objects, and JsonArrayBuilder which builds Json arrays. With just these two builders we have all the tools needed to build Json arrays and Json objects. Once we have obtained an instance of one of these two factories we start the construction process by calling an add method and passing it the property name and the property value. It is possible to nest Json objects and arrays by passing a new instance with the builder as a the value of a property. Here is a simple example that constructs a Json object with a single string property and an array property. This Json object is constructed by creating a Json object builder and including the add…
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)
-
-