[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/lib/yui/json/ -> json.js (summary)

Provides methods to parse JSON strings and convert objects to JSON strings.

File Size: 396 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 7 functions

  _revive()
  _char()
  _prepare()
  _isValid()
  _string()
  _stringify()
  _zeroPad()

Functions
Functions that are not part of a class:

_revive(data, reviver)   X-Ref
Traverses nested objects, applying a filter or reviver function to
each value.  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.

param: data {MIXED} Any JavaScript data
param: reviver {Function} filter or mutation function
return: {MIXED} The results of the filtered/mutated data structure

_char(c)   X-Ref
Escapes a special character to a safe Unicode representation

param: c {String} single character to escape
return: {String} safe Unicode escape

_prepare(s)   X-Ref
Replace certain Unicode characters that may be handled incorrectly by
some browser implementations.

param: s {String} parse input
return: {String} sanitized JSON string ready to be validated/parsed

_isValid(str)   X-Ref
Four step determination whether a string is valid JSON.  In three steps,
escape sequences, safe values, and properly placed open square brackets
are replaced with placeholders or removed.  Then in the final step, the
result of all these replacements is checked for invalid characters.

param: str {String} JSON string to be tested
return: {boolean} is the string safe for eval?

_string(s)   X-Ref
Enclose escaped strings in quotes

param: s {String} string to wrap
return: {String} '"'+s+'"' after s has had special characters escaped

_stringify(h,key,d,w,pstack)   X-Ref
Worker function used by public stringify.

param: h {Object} object holding the key
param: key {String} String key in object h to serialize
param: depth {Number} depth to serialize
param: w {Array|Function} array of whitelisted keys OR replacer function
param: pstack {Array} used to protect against recursion
return: {String} serialized version of o

_zeroPad(v)   X-Ref
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.

param: d {Date} The Date to serialize
return: {String} stringified Date in UTC format YYYY-MM-DDTHH:mm:SSZ



Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7