Skip to content

JSON.parse

Signature: JSON.parse(value)

Returns: Object jsonObject - the JSON object for the given value

Converts the value string to a JSON Object.

Parameters

Type Name Description Default
String value the JSON string to be converted

Example

// Example: Parse a JSON string into a JavaScript object.

// Sample JSON string
var jsonString = '{ "name": "John Doe", "age": 30, "city": "New York" }';

// Parse JSON string into an object
var jsonObject = JSON.parse(jsonString);

// Access parsed values
var name = jsonObject.name; // "John Doe"
var age  = jsonObject.age;  // 30