JSON. stringify( ) function in JavaScript


The stringify() function of a JSON object accepts a JSON string, and constructs an object based on the given text and, returns it.

Syntax

Its Syntax is as follows

Json.stringify();

Example

 Live Demo

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var jsonSample = '{Tutorial: Java, Version:8}';
      jsonObj = JSON.stringify(jsonSample);
      document.write(jsonObj);
   </script>
</body>
</html>

Output

"{Tutorial: Java, Version:8}"

Updated on: 25-Jun-2020

189 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements