<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>JSON fields</title>
</head>
<body>
<script>
jarr = JSON.parse('{"id":"1","name":"GK","log":[{"var1":"11","var2":"12","var3":"13"},{"var1":"21","var2":"22","var3":"23","var4":"24"}]}');
for (objk in jarr) {
if (Array.isArray(jarr[objk])) { // Check if the object is an array
console.log(objk+'[array]');
for( obindex in jarr[objk] ) { // Go over the objects in the array
console.log(obindex , jarr[objk][obindex]); // show the object
var jar = jarr[objk][obindex]; // Get the JSON dictionary
for (k1 in jar) { // k is the key in ar
console.log(k1,jar[k1]); // show all the key - value in the objects on the array of log
}
}
} else {
console.log(objk+'{key}', jarr[objk]); // A simple JSON dictioanry
}
}
</script>
</body>
</html>