Get the values from the json by parsing and accessing its element - Javascript JSon

Javascript examples for JSon:JSon Parse

Description

Get the values from the json by parsing and accessing its element

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  ww w. ja v a  2  s  .  com
var json = '[{"pk": 1, "model": "gps.test", "fields": {"hi": 23.1, "hello": 47.916142}}]';
var a = JSON.parse(json);
console.log(a[0].fields.hi)
console.log(a[0].fields.hello)
    }

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

Related Tutorials