Answer the question
In order to leave comments, you need to log in
How to count number of keys in json?
Json with multiple nesting levels.
names = JSON.parse(ch, function(key, value){
var b = 0;
if(key.length > 0){
b = b+1;
}
console.log(b);
});
for(i in names){
if( typeof names[i] === 'object'){
names = names[i];
len = len + Object.keys(names).length;
console.log("len temp", len);
}
}
Answer the question
In order to leave comments, you need to log in
var jsonString = "{... your json string ...}";
console.log(jsonString.match(/[^\\]":/g).length);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question