A parser to read/write JSON safely.
Inherits from
NAME | DESCRIPTION |
---|---|
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. |
level | {Integer} For “pretty” printing, this is incremented/decremented during serialization. |
pretty | {Boolean} Serialize with extra whitespace for structure. |
NAME | DESCRIPTION |
---|---|
ZOO.Format.JSON | Create a new parser for JSON. |
read | Deserialize a json string. |
write | Serialize an object into a JSON string. |
writeIndent | Output an indentation string depending on the indentation level. |
writeNewline | Output a string representing a newline if in pretty printing mode. |
writeSpace | Output a string representing a space if in pretty printing mode. |
NAME | DESCRIPTION |
---|---|
serialize | Object with properties corresponding to the serializable data types. |
NAME | DESCRIPTION |
---|---|
serialize.object | Transform an object into a JSON string. |
serialize.array | Transform an array into a JSON string. |
serialize.string | Transform a string into a JSON string. |
serialize.number | Transform a number into a JSON string. |
serialize.boolean | Transform a boolean into a JSON string. |
serialize.date | Transform a date into a JSON string. |
Properties
Functions
Create a new parser for JSON.
Parameters
options {Object} An optional object whose properties will be set on this instance.
read: function(json,filter)
Deserialize a json string.
Parameters
Returns
{Object} An object, array, string, or number.
write: function(value,pretty)
Serialize an object into a JSON string.
Parameters
Returns
{String} The JSON string representation of the input value.
writeIndent: function()
Output an indentation string depending on the indentation level.
Returns
{String} An appropriate indentation string.
writeNewline: function()
Output a string representing a newline if in pretty printing mode.
Returns
{String} A string representing a new line.
writeSpace: function()
Output a string representing a space if in pretty printing mode.
Returns
{String} A space.
Serialize Properties
Serialize Functions
Transform an object into a JSON string.
Parameters
object {Object} The object to be serialized.
Returns
{String} A JSON string representing the object.
Transform an array into a JSON string.
Parameters
array {Array} The array to be serialized
Returns
{String} A JSON string representing the array.
Transform a string into a JSON string.
Parameters
string {String} The string to be serialized
Returns
{String} A JSON string representing the string.
Transform a number into a JSON string.
Parameters
number {Number} The number to be serialized.
Returns
{String} A JSON string representing the number.
Transform a boolean into a JSON string.
Parameters
bool {Boolean} The boolean to be serialized.
Returns
{String} A JSON string representing the boolean.
Transform a date into a JSON string.
Parameters
date {Date} The date to be serialized.
Returns
{String} A JSON string representing the date.