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.

How to traverse the model

How to traverse the model

From the course: JSON Processing with Java EE

Start my 1-month free trial

How to traverse the model

- [Instructor] Once a model has been constructed, we can navigate the model and inspect its keys and values. In this video, we're going to look at two ways of traversing the JSON model. Remember that in an earlier video, we talked about how all types within the JSON model extend from JsonValue. Well, we're going to use this knowledge to construct a method that traverses the JSON tree and extracts its values. We're going to implement this in two contrasting ways. For the first method, we're going to use the ValueType to determine how to treat the JsonValue object. And for the second, we're going to use polymorphism to select the right method to deal with a JsonValue object. Let's have a closer look at the methodology we're going to use to construct the first traversal code. We're going to use the ValueType information that we can extract from the JsonValue instants. We know that by calling the get value type method, we can determine the internal type represented by this object with one…

Contents