JSON - Return Property Count <p><strong>JSON structure:</strong></p> <pre><code>{ "codes":[ { "id":"1", "code":{ "fname":"S", "lname":"K" } }, { "id":"2", "code":{ "fname":"M", "lname":"D" } } ] } </code></pre> <p><strong>I want to loop through each code and alert the number of properties within each code</strong></p> <pre><code> success: function(data){ var x, count=0; for (x = 0; x &lt; data.codes.length; x++){ for (property in data.codes[x].code) { count++; alert(count); } } } </code></pre> <p><strong>The above works BUT it returns 4 as the <code>count</code>. It should return 2 for each <code>code</code>.</strong></p>