Looping through dynamic JSON data using javascript <p>I am trying to display JSON data but the key value is dynamic it varies from one POST request to another my data hierarchy is as shown in diagram:</p> <p><a href="https://i.stack.imgur.com/tPCQa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tPCQa.png" alt=""></a></p> <p>This is the part of the code I am running,Can anyone suggest me how to display JSON data where key showed in redbox gonna change for every POST request</p> <pre><code>$.ajax({ type: "POST", url: "/", dataType:'json', data : { 'perfid': valueOne, 'hostname': $("#host").val(), 'iteration': valueThree}, success: function(data) { $('#img1').hide(); var k = data[$("#host").val()].iscsi_lif.result.sectoutput.sect.length; for(var i = 0; i &lt; k; i++) { var obj = k[i]; console.log(obj); var iscsi = parseInt(data[$("#host").val()].iscsi_lif.result.sectoutput.sect.obj.avg_latency); console.log(iscsi); } </code></pre> <p>While running above snippet I am getting following error message :</p> <p>data[$(....).val(...)].iscsi_lif.result.sectoutput.sect is undefined</p>