Answers for "json traversal in js"

0

json traversal in js

Object.entries(jsonObj).forEach(([key, value]) => {
    // do something with key and val
});
Posted by: Guest on October-23-2020
0

json traversal in js

function traverse(jsonObj) {
    if( jsonObj !== null && typeof jsonObj == "object" ) {
        Object.entries(jsonObj).forEach(([key, value]) => {
            // key is either an array index or object key
            traverse(value);
        });
    }
    else {
        // jsonObj is a number or string
    }
}
Posted by: Guest on October-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language