The JSON namespace is added to your YUI instance including static methods Y.JSON.parse(..) and Y.JSON.stringify(..).
The functionality and method signatures follow the ECMAScript 5 specification. In browsers with native JSON support, the native implementation is used.
json module is a rollup of
As their names suggest,
json-parse adds support for parsing
JSON data (Y.JSON.parse) and
json-stringify for serializing
include either of the submodules individually if you don't need the
complementary functionality, or include the rollup for both.
Traverses nested objects, applying a reviver function to each (key,value) from the scope if the key:value's containing object. The value returned from the function will replace the original value in the key:value pair. If the value returned is undefined, the key will be omitted from the returned object.
filter or mutation function
The results of the filtered data
Create a custom transport of type and return it's object
The id of the transport to create.
Serializes a Date instance as a UTC date string. Used internally by stringify. Override this method if you need Dates serialized in a different format.
The Date to serialize
stringified Date in UTC format YYYY-MM-DDTHH:mm:SSZ
The transport to set as the default, if empty a new transport is created.
The transport object with a
Replaces specific unicode characters with their appropriate \unnnn format. Some browsers ignore certain characters during eval.
the \unnnn escapement of the character
Fired from the notify method of the transport which in turn fires the event on the IO object.
Converts an arbitrary value to a JSON string representation.
Objects with cyclical references will trigger an exception.
If a whitelist is provided, only matching object keys will be included. Alternately, a replacer function may be passed as the second parameter. This function is executed on every value in the input, and its return value will be used in place of the original value. This is useful to serialize specialized objects or class instances.
If a positive integer or non-empty string is passed as the third parameter, the output will be formatted with carriage returns and indentation for readability. If a String is passed (such as "\t") it will be used once for each indentation level. If a number is passed, that number of spaces will be used.
JSON string representation of the input
Third step in the safety evaluation. Regex used to remove all open square brackets following a colon, comma, or at the beginning of the string.
The ID of the default IO transport, defaults to
First step in the safety evaluation. Regex used to replace all escape sequences (i.e. "\", etc) with '@' characters (a non-JSON character).
Final step in the safety evaluation. Regex used to test the string left after all previous replacements for invalid characters.
Second step in the safety evaluation. Regex used to replace all simple values with ']' characters.
Number of occurrences of a special character within a single call to stringify that should trigger promotion of that character to a dedicated preprocess step for future calls. This is only used in environments that don't support native JSON, or when useNativeJSONStringify is set to false.
So, if set to 50 and an object is passed to stringify that includes strings containing the special character \x07 more than 50 times, subsequent calls to stringify will process object strings through a faster serialization path for \x07 before using the generic, slower, replacement process for all special characters.
To prime the preprocessor cache, set this value to 1, then call
Y.JSON.stringify("(all special characters to
cache)");, then return this setting to a more conservative
Special characters \ " \b \t \n \f \r are already cached.
An object hash of custom transports available to IO