namespace bot.json

Functions

parse(jsonStr)code »

Parses a JSON string and returns the result.

Parameters
jsonStrstring

The string to parse.

Returns

The JSON object.

Throws
Error

If the input string is an invalid JSON string.


stringify(jsonObj, opt_replacer)code »

Converts a JSON object to its string representation.

Parameters
jsonObj*

The input object.

opt_replacer?function(string, *): *=

A replacer function called for each (key, value) pair that determines how the value should be serialized. By default, this just returns the value and allows default serialization to kick in.

Returns
string

A JSON string representation of the input object.

Compiler Constants

NATIVE_JSONboolean

NATIVE_JSON indicates whether the code should rely on the native JSON functions, if available.

The JSON functions can be defined by external libraries like Prototype and setting this flag to false forces the use of Closure's goog.json implementation.

If your JavaScript can be loaded by a third_party site and you are wary about relying on the native functions, specify "--define bot.json.NATIVE_JSON=false" to the Closure compiler.