OpenLayers.Format.JSON

A parser to read/write JSON safely.  Create a new instance with the OpenLayers.Format.JSON constructor.

Inherits from

Summary
OpenLayers.Format.JSONA parser to read/write JSON safely.
Properties
indent{String} For “pretty” printing, the indent string will be used once for each indentation level.
space{String} For “pretty” printing, the space string will be used after the “:” separating a name/value pair.
newline{String} For “pretty” printing, the newline string will be used at the end of each name/value pair or array item.
Constructor
OpenLayers.Format.JSONCreate a new parser for JSON.
Functions
readDeserialize a json string.
writeSerialize an object into a JSON string.

Properties

indent

{String} For “pretty” printing, the indent string will be used once for each indentation level.

space

{String} For “pretty” printing, the space string will be used after the “:” separating a name/value pair.

newline

{String} For “pretty” printing, the newline string will be used at the end of each name/value pair or array item.

Constructor

OpenLayers.Format.JSON

Create a new parser for JSON.

Parameters

options{Object} An optional object whose properties will be set on this instance.

Functions

read

read: function(json,
filter)

Deserialize a json string.

Parameters

json{String} A JSON string
filter{Function} A function which will be called for every key and value at every level of the final result.  Each value will be replaced by the result of the filter function.  This can be used to reform generic objects into instances of classes, or to transform date strings into Date objects.

Returns

{Object} An object, array, string, or number .

write

write: function(value,
pretty)

Serialize an object into a JSON string.

Parameters

value{String} The object, array, string, number, boolean or date to be serialized.
pretty{Boolean} Structure the output with newlines and indentation.  Default is false.

Returns

{String} The JSON string representation of the input value.

read: function(json,
filter)
Deserialize a json string.
write: function(value,
pretty)
Serialize an object into a JSON string.
Create a new parser for JSON.
Base class for format reading/writing a variety of formats.
Close