A parser to read/write JSON safely. Create a new instance with the ALKMaps.Format.JSON constructor.
ALKMaps. | A 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. |
level | {Integer} For “pretty” printing, this is incremented/decremented during serialization. |
pretty | {Boolean} Serialize with extra whitespace for structure. |
nativeJSON | {Boolean} Does the browser support native json? |
Constructor | |
ALKMaps. | Create a new parser for JSON. |
Functions | |
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. |
Properties | |
serialize | Object with properties corresponding to the serializable data types. |
Functions | |
serialize. | Transform an object into a JSON string. |
serialize. | Transform an array into a JSON string. |
serialize. | Transform a string into a JSON string. |
serialize. | Transform a number into a JSON string. |
serialize. | Transform a boolean into a JSON string. |
serialize. | Transform a date into a JSON string. |
{Boolean} Serialize with extra whitespace for structure. This is set by the write method.
read: function( json, filter )
Deserialize a json string.
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. |
{Object} An object, array, string, or number .
write: function( value, pretty )
Serialize an object into a JSON string.
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. |
{String} The JSON string representation of the input value.
Deserialize a json string.
read: function( json, filter )
Serialize an object into a JSON string.
write: function( value, pretty )
Output an indentation string depending on the indentation level.
writeIndent: function()
Output a string representing a newline if in pretty printing mode.
writeNewline: function()
Output a string representing a space if in pretty printing mode.
writeSpace: function()