Javascript examples for Array Operation:Associative Array
Convert From JSON to Associative array
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w ww . j a v a2 s . c om*/ var text = '{ "employees" : [' + '{ "firstName":"John" , "lastName":"Doe" },' + '{ "firstName":"Anna" , "lastName":"Smith" },' + '{ "firstName":"Peter" , "lastName":"Jones" } ]}'; var obj = JSON.parse(text); console.log(obj); console.log(obj.employees[0].firstName); } </script> </head> <body> </body> </html>