# Namespace goog.json

code »

## Classes

goog.json.Serializer Class that is used to serialize JSON objects to a string.

Show:Public Protected Private

## Type Definitions

code »goog.json.Replacer : `function(this: Object, string, *): *`
JSON replacer, as defined in Section 15.12.3 of the ES5 spec. TODO(nicksantos): Array should also be a valid replacer.
code »goog.json.Reviver : `function(this: Object, string, *): *`
JSON reviver, as defined in Section 15.12.2 of the ES5 spec.

## Global Functions

code »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

Parameters
s: `string` The string to test.
Returns
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.

Parameters
s: `*` The JSON string to parse.
Returns
The object generated from the JSON string.

code »goog.json.serialize ( object, opt_replacer ) ⇒ `string`

Serializes an object or a value to a JSON string.

Parameters
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
A JSON string representation of the input.
Throws
if there are loops in the object graph.

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.

Parameters
s: `string` The JSON string to parse.
Returns
The object generated from the JSON string.