Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <h2>Create Object from JSON String</h2> <p id="demo"></p> <script> var text = '{"employees":[' + '{"firstName":"John","lastName":"Doe" },' + '{"firstName":"Anna","lastName":"Smith" },' + '{"firstName":"Peter","lastName":"Jones" }]}'; obj = JSON.parse(text); document.getElementById("demo").innerHTML = obj.employees[1].firstName + " " + obj.employees[1].lastName; </script> </body> <!-- Mirrored from www.w3schools.com/json/tryit.asp?filename=tryjson_parse by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:40:58 GMT --> </html>
Result:
Try it Yourself - © w3schools.com