Solved: Iterate over JSON Object for given list of keys using using Java 8 stream

Question:

I have list of keys
And below is the JSONObject
I would like to iterate over above JSONObject for given json keys (traverses) using Lambda.
I have achieved it using traditional way
But looking for advanced way (using Stream/Lambda) to achieve the same.

Best Answer:

This is equivalent to your loop:
It uses the reduce method which unfortunately requires a combiner argument that doesn’t make much sense. Fortunately, it doesn’t actually call it in this case, so I just made it return null.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com