Hi everyone, I am trying to find the most dynamic way to loop through an array and return certain values, return certain values ββ... json is deeply structured and can change, maybe the $ .each () formula can help?
Example:
var myobj = { obj1: { key1: 'val1', key2: 'val2' }, obj2: { key1: '2val1', key2: { nest1: 'val1', nest2: 'val2', nest3: 'val3' }, key3: { nest1: 'K3val1', nest2: 'K3val2', nest3: [ { nest1: 'val1', nest2: 'val2', nest3: 'val3' }, { nest1: 'val1', nest2: 'val2', nest3: 'val3' } ] } }, obj3: { key1: 'dddddval1', key2: 'val2' } }
Now we can say that I want to get the value " K3val2 ", but instead of hard coding it looks like this: myobj.obj2.key3.nest2 is there a dynamic way that I do using $.each() mybe?
source share