Parsing an enumerated array of arrays from a string using Json parse - Javascript JSon

Javascript examples for JSon:JSon Parse

Description

Parsing an enumerated array of arrays from a string using Json parse

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.ja  va 2 s .  c om

var sourceData = '["US", 7.0287],["Canada", 7.3005]';

resultArray = JSON.parse("[" + sourceData + "]");

for(var i = 0; i < resultArray.length; i++) {
    console.log(resultArray[i]);
}

    }

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

Related Tutorials