Loop through nested objects with jQuery

Hey everyone I am trying t find the most dynamic way to loop through an array & return specific values return specific values… The json is deeply structured & may change, could there be a $.each() formula that can help?

Example:

now lets say i want to retrieve “K3val2” value yet instead of hardcoding it like so: myobj.obj2.key3.nest2 is there a dynamic way I do this with $.each() mybe?

You can simply nest calls to $.each:

Live Example | Live Source

If you want to know how deep you are, you can do that too:

Live Example | Live Source