1Object.entries(jsonObj).forEach(([key, value]) => {
2 // do something with key and val
3});
4
1function traverse(jsonObj) {
2 if( jsonObj !== null && typeof jsonObj == "object" ) {
3 Object.entries(jsonObj).forEach(([key, value]) => {
4 // key is either an array index or object key
5 traverse(value);
6 });
7 }
8 else {
9 // jsonObj is a number or string
10 }
11}
12