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.

Solution: Find the value of a JSON key

Solution: Find the value of a JSON key

From the course: JSON Processing with Java EE

Start my 1-month free trial

Solution: Find the value of a JSON key

(light, inquisitive music) - [Instructor] So, how did you get on with your first streaming model challenge? Here's how I solved it. As you can see, all I do is to create a parser by passing it the JSON data I want to search, and iterate over the events generated by the parser. I filter on the key_name event, test the key_name against the key provided, and only return a value if it is a string or a number. Otherwise, I return null. A more sophisticated example might also return arrays and objects as strings, but I'll leave that up to you to do.

Contents