Count object in Json array - Javascript JSon

Javascript examples for JSon:JSon Object

Description

Count object in Json array

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from  w  w w.java  2  s. c  o  m
var arr ={"1":{"my_id":"1","my_model":"A.5","my_type":"p","my_return":"aaa"},
          "2":{"my_id":"2","my_model":"B.5","my_type":"a","my_return":"vvv"}};
var len = 0;
for(var i in arr) 
   len++;
console.log(len);
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials