Parse Json with dynamic key with JQuery

<script
 src="http://code.jquery.com/jquery-3.1.0.min.js"
 integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s="
 crossorigin="anonymous"></script>
<script>

var json ={
"result":
{
"101010":["PRAVAT","SGSGSG","UKEMP5","UKENTD","WAUK01","MK87UK"],
"202020":["CORA1E","PSASAS","EDCRJS","USHC01","USDR06"],
"304050":["ERCDE2","DELT01","DECGKG","DEHC03","IS02","DEPI01"]
},
"status":"SUCCESS"
};

var obj = jQuery.parseJSON(JSON.stringify(json));
if (obj.status.toLowerCase() === "success") {
for (var key in obj.result) {
console.log("key >> "+key);
if (obj.result.hasOwnProperty(key)) {
  console.log(key + ': ' + obj.result[key]);
}
}
}
}
</script>
 
<body onload="jsonParse()"></body>

Comments

Popular posts from this blog

Simple Invoice Creation With Jasper Report

Dynamic Image in Jasper Report

Auto Increment Oracle Table Id Mapping With JPA Entity