Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
    }
}
Comment

json traversal in js

Object.entries(jsonObj).forEach(([key, value]) => {
    // do something with key and val
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: vuejs get data fromo ajax 
Javascript :: java script or js circle collision 
Javascript :: array.filter in javascript 
Javascript :: load js 
Javascript :: what to use let vs var js 
Javascript :: react hero slider 
Javascript :: react insert variable into string 
Javascript :: update state in useState hook 
Javascript :: how to add class in javascript dynamically 
Javascript :: uuid react native expo 
Javascript :: Install PHP debugbar 
Javascript :: pass element from child to parent react 
Javascript :: GET FORM VALUE 
Javascript :: how to decode jwt token client side 
Javascript :: updatig state in react 
Javascript :: js bind prototype arrow function 
Javascript :: js arrow anonymous function 
Javascript :: nodemon writefilesync restart problem 
Javascript :: compare date value in javascript 
Javascript :: mobile detect js 
Javascript :: promise in es6 
Javascript :: sequelize 
Javascript :: js push 
Javascript :: how to create new route in express 
Javascript :: read string using stream nodejs 
Javascript :: js callback hell 
Javascript :: js foreach mdn 
Javascript :: find if json property is of type date type 
Javascript :: js string includes count 
Javascript :: Difference between “ == “ and “ === “ operators. 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =