Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JS_ParseJSON

This article covers features introduced in SpiderMonkey 1.8.6

Parse a string using the JSON syntax described in ECMAScript 5 and return the corresponding value.

Syntax

JSBool JS_ParseJSON(JSContext *cx, const jschar *chars, uint32 len, jsval *vp);
JSBool JS_ParseJSONWithReviver(JSContext *cx, const jschar *chars, uint32 len, jsval reviver, jsval *vp);
Name Type Description
cx JSContext * Pointer to a JS context. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
ch JSObject * The object to be searched.
chars const jschar * The characters of the string.
len uint32 The length of the string.
index jsint (in JS_ParseJSONWithReviver only) A reviver function to apply to the created value after parsing; see JSON.parse.
vp jsval * Out parameter. *vp receives the value after parsing (and optionally, processing by the reviver). If an error occurs, the value left in *vp is undefined.

Description

Use these functions to parse a sequence of characters as JSON.  The parsing rules applied by these methods are exactly those specified by ECMAScript 5.  Various JSON extensions like trailing commas, unquoted property names, more generous number parsing, and so on are not supported.

MXR ID Search for JS_ParseJSON
MXR ID Search for JS_ParseJSONWithReviver

Document Tags and Contributors

 Contributors to this page: fscholz, markg, Waldo
 Last updated by: fscholz,