Parse Json string to Json object - Javascript JSon

Javascript examples for JSon:JSon Parse

Description

Parse Json string to Json object

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(){/* www.java  2s . co  m*/
var str = '{"channels": [
   {"name": "video1","image": "images/bodyguard.jpg"},
   {"name": "video2","image": "images/bodyguard.jpg"},
   {"name": "video3","image": "images/bodyguard.jpg"}]}';
   
var obj = JSON.parse(str);
console.log(obj.channels.length);
    }

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

Related Tutorials