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

JSON Stringify

JSON Stringify

JSON stringify is the process of converting a javaScript object in JSON object that can be used inside a program. when You sending data to a web server, the data should be in string format. So you need to convert a JavaScript object into a string with JSON.stringify().

Json stringify


Suppose we have a object in JavaScript as following:

const javascriptobject={name:"Rohatash", age:36, email:""};

Use the JavaScript function JSON.stringify() to convert JavaScript object into a string.

const myJSON = JSON.stringify(javascriptobject);

The below example you can use on HTML page


<h2>JSON String from a JavaScript Object </h2>

<p id="parsetestid"></p>

const javascriptobject= {name:"Rohatash", age:36, email:""};
const myJSON = JSON.stringify(javascriptobject);
document.getElementById("parsetestid").innerHTML = myJSON


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


Json stringify

Prev Next