jQuery parseJSON() Method

Last Updated:

jQuery parseJSON() Method

The jQuery parseJSON() method takes a well-formed JSON string and returns the resulting JavaScript value.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery parseJSON() Method</h1> <p>Click on the button to alert name.</p> <button>Click Me</button> <script> $(document).ready(function(){ $("button").click(function(){ var str = '{"name": "Jade", "age": 18, "hair": "brunette"}'; str = $.parseJSON(str); alert(str.name); }); }); </script> </body> </html>

Syntax

$.parseJSON(str);

Parameter Values

ValueTypeExplanation
str Required Specifies a JSON string.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
parseJSON()YesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author