How to use 'foreach json object' in JavaScript

Every line of 'foreach json object' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
48function _do(f) {
49 var i, values;
50 for(; a
134function jsonParser(json) {
135 // Number fo indentation
136 n = 2;
137 // Start the loop
138 json.forEach(function(root){
139 root.child.forEach(function(child){
140 // If line doesn't have HB tag
141 if(root.tags.length < 1){
142 child.indent = root.indent+n;
143 }
144 // If line has HB tag and start with HB tag and not comment
145 else if(root.tags.length > 0 && root.tags[0].position == 0 && !root.content.match(/^\/\/\-*.*/)) {
146 child.indent = root.indent;
147 }
148 else if(root.tags.length > 0 && root.tags[0].position != 0 && !root.content.match(/^\/\/\-*.*/)) {
149 child.indent = root.indent+n;
150 }
151 // If child has child, recursive call
152 if(child.child.length > 0)
153 jsonParser([child]);
154 });
155 });
156 return json;
157}

Related snippets