This Angular tutorial helps you get started with Angular quickly and effectively through many practical examples.

JSON JavaScript Example

The below example show how we can use JSON data in JavaScript Application.


Suppose we have a web API and it is uploaded on web server. So we received this text from a web server:

'{"name":"Rohatash", "age":36, "Email":""}'

Use the JavaScript function JSON.parse() to convert text into a JavaScript object:

const parseobj = JSON.parse('{{"name":"Rohatash", "age":36, "Email":""}}');

The below example you can use on HTML page

<h2>JavaScript Object from a JSON String</h2>
<p id="parsetestid"></p>
   const jsontxt = '{"name":"Rohatash", "age":36, "Email":""}'
   const obj = JSON.parse(jsontxt);
   document.getElementById("parsetestid").innerHTML = + ", " + obj.age + ", " + obj.Email;

Now run the code on browser. The following output will show:


Json JavaScript Example

Prev Next