# Class goog.json.Serializer

code »

Class that is used to serialize JSON objects to a string.

## Constructor

goog.json.Serializer ( opt_replacer )

Parameters
opt_replacer: `?goog.json.Replacer=` Replacer.

Show:Public Protected Private

## Instance Methods

code »serialize ( object ) ⇒ `string`

Serializes an object or a value to a JSON string.

Parameters
object: `*` The object to serialize.
Returns
A JSON string representation of the input.
Throws
if there are loops in the object graph.

code »serializeArray ( arr, sb )

Serializes an array to a JSON string

Parameters
arr: `Array` The array to serialize. sb: `Array` Array used as a string builder.

code »serializeInternal ( object, sb )

Serializes a generic value to a JSON string

Parameters
object: `*` The object to serialize. sb: `Array` Array used as a string builder.
Throws
if there are loops in the object graph.

code »serializeNumber_ ( n, sb )

Serializes a number to a JSON string

Parameters
n: `number` The number to serialize. sb: `Array` Array used as a string builder.

code »serializeObject_ ( obj, sb )

Serializes an object to a JSON string

Parameters
obj: `Object` The object to serialize. sb: `Array` Array used as a string builder.

code »serializeString_ ( s, sb )

Serializes a string to a JSON string

Parameters
s: `string` The string to serialize. sb: `Array` Array used as a string builder.

## Instance Properties

code »replacer_ : `(goog.json.Replacer|null|undefined)`

## Static Properties

code »goog.json.Serializer.charToJsonCharCache_ : `!Object`

Character mappings used internally for goog.string.quote

code »goog.json.Serializer.charsToReplace_ : `!RegExp`

Regular expression used to match characters that need to be replaced. The S60 browser has a bug where unicode characters are not matched by regular expressions. The condition below detects such behaviour and adjusts the regular expression accordingly.