JSON.parse() function in JavaScript

JavascriptHTMLWeb DevelopmentFront End Technology

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

Syntax

Its Syntax is as follows

Json.parse();

Example

 Live Demo

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

Output

Tutorial Name: Java
Tutorial Version: 8
raja
Published on 26-Oct-2018 06:41:12
Advertisements