Wednesday, 20 April 2016

JSON - Evaluates to JavaScript Objects :::::: HEMANT VISHWAKARMA

CODE :

<!DOCTYPE html>
<html>
<body>

<h2>JSON Object Creation in JavaScript</h2>

<p id="demo"></p>

<script>
var text = '{"name":"John Johnson","street":"Oslo West 16","phone":"555 1234567"}';

var obj = JSON.parse(text);

document.getElementById("demo").innerHTML =
obj.name + "<br>" +
obj.street + "<br>" +
obj.phone;
</script>

</body>

</html>

OUTPUT:

JSON Object Creation in JavaScript


John Johnson
Oslo West 16
555 1234567

No comments:

Post a Comment