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
<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