Parse string to Json object - Javascript JSon

Javascript examples for JSon:JSon Parse

Description

Parse 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(){//w  w w.  ja va2s .co  m
var x = document.getElementById('pids').innerText;
var y = JSON.parse(x);
console.log(y.length);
    }

      </script> 
   </head> 
   <body> 
      <span id="pids" style="display:none">["26551826","22956811","22959266"]</span>  
   </body>
</html>

Related Tutorials