json

Classes

goog.json.EvalJsonProcessor
A class that parses and stringifies JSON using eval (as implemented in goog.json). Adapts goog.json to the goog.json.Processor interface.
goog.json.HybridJsonProcessor
Processor form of goog.json.hybrid, which attempts to parse/serialize JSON using native JSON methods, falling back to goog.json if not available.
goog.json.NativeJsonProcessor
A class that parses and stringifies JSON using the browser's built-in JSON library, if it is avaliable. Note that the native JSON api has subtle differences across browsers, so use this implementation with care. See json_test#assertSerialize for details on the differences from goog.json. This implementation is signficantly faster than goog.json, at least on Chrome. See json_perf.html for a perf test showing the difference.
goog.json.Processor
An interface for JSON parsing and serialization.
goog.json.Serializer
Class that is used to serialize JSON objects to a string.

Public Protected Private

Global Functions

goog.json.isValid_(s) boolean
Tests if a string is an invalid JSON string. This only ensures that we are not using any invalid characters
Arguments:
s : string
The string to test.
Returns: boolean  True if the input is a valid JSON string.
code »
goog.json.parse(s) Object
Parses a JSON string and returns the result. This throws an exception if the string is an invalid JSON string. Note that this is very slow on large strings. If you trust the source of the string then you should use unsafeParse instead.
Arguments:
s : *
The JSON string to parse.
Returns: Object  The object generated from the JSON string, or null.
code »
goog.json.serialize(objectopt_replacer) string
Serializes an object or a value to a JSON string.
Arguments:
object : *
The object to serialize.
opt_replacer : ?goog.json.Replacer=
A replacer function called for each (key, value) pair that determines how the value should be serialized. By defult, this just returns the value and allows default serialization to kick in.
Returns: string  A JSON string representation of the input.
code »
goog.json.unsafeParse(s) Object
Parses a JSON string and returns the result. This uses eval so it is open to security issues and it should only be used if you trust the source.
Arguments:
s : string
The JSON string to parse.
Returns: Object  The object generated from the JSON string.
code »

Global Properties

goog.json.HybridJsonProcessorTest :
No description.
Code »
goog.json.Replacer :
JSON replacer, as defined in Section 15.12.3 of the ES5 spec.
Code »
goog.json.Reviver :
JSON reviver, as defined in Section 15.12.2 of the ES5 spec.
Code »
goog.json.USE_NATIVE_JSON :
No description.
Code »
goog.json.hybrid :
No description.
Code »
goog.json.hybridTest :
No description.
Code »
goog.json.processorTest :
No description.
Code »

Package json

Package Reference