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.

Traverse the JSON model

Traverse the JSON model

From the course: JSON Processing with Java EE

Start my 1-month free trial

Traverse the JSON model

- [Instructor] So, let's get started with the JSON model. I'm gonna scroll down to the bottom of this class, and what I have here is a method called load JSON object. And what this method does is it creates a JSON object. This code might look familiar to you. It is actually a copy of the code we used in an earlier lesson. When I call the load JSON object method, it returns a JSON object that represents the JSON data that we've been using in this course. So the objective here is to write code that traverses the object model and prints out the model's data to the console. So let's get started. What I've done here is I've created a main method, and within the main method, I call a method called navigate JSON structure, and I pass the navigate JSON structure, the JSON object. And within the navigate JSON structure, we have a switch statement. And the switch statement retrieves the value type from the JSON value, and with that value type, it selects an action to perform. So if the value…

Contents