Json

License

MIT-style license.

Author

Takashi Mizohata bea.nosp@m.tak@nydd.nosp@m..org

Copyright

2008 [nydd](http://code.nydd.org/).

Code & Documentation

[nydd jslib](http://code.nydd.org/).

Inspiration

Summary
JsonMIT-style license.
Constants
REGEX_BSLASHFor Regex optimization: BSLASH means “backslash”
REGEX_DQUOTEFor Regex optimization: DQUOTE means “double quote”
REGEX_FSLASHFor Regex optimization: FSLASH means “forwardslash”
REGEX_BSFor Regex optimization: BS means “backspace”
REGEX_FFFor Regex optimization: FF means “form feed”, invisible character
REGEX_LFFor Regex optimization: LF means “linefeed”
REGEX_CRFor Regex optimization: CR means “carrige return”
REGEX_TABFor Regex optimization: TAB means “horizontal tab”
Functions
encodeDispatcher method for every JSON serialization.
encodeArrayEncode array into JSON String.
encodeBooleanEncode boolean into JSON String.
encodeFunction[FIX ME] Encode function into JSON String.
encodeNullEncode null into JSON String.
encodeNumberEncode number into JSON String.
encodeObjectEncode object into JSON String.
encodeStringEncode string into JSON String.
encodeUndefinedEncode undefined into JSON String.

Constants

REGEX_BSLASH

For Regex optimization: BSLASH means “backslash”

Content

BSLASHnew RegExp(/\u005C/g)

REGEX_DQUOTE

For Regex optimization: DQUOTE means “double quote”

Content

DQUOTEnew RegExp(/\u0022/g)

REGEX_FSLASH

For Regex optimization: FSLASH means “forwardslash”

Content

FSLASHnew RegExp(/\u002F/g)

REGEX_BS

For Regex optimization: BS means “backspace”

Content

BSnew RegExp(/\u0008/g)

REGEX_FF

For Regex optimization: FF means “form feed”, invisible character

Content

FFnew RegExp(/\u000C/g)

REGEX_LF

For Regex optimization: LF means “linefeed”

Content

LFnew RegExp(/\u000A/g)

REGEX_CR

For Regex optimization: CR means “carrige return”

Content

CRnew RegExp(/\u000D/g)

REGEX_TAB

For Regex optimization: TAB means “horizontal tab”

Content

TABnew RegExp(/\u0009/g)

Functions

encode

Json.encode = function (obj)

Dispatcher method for every JSON serialization.  Soemthing that cannot be serialzied (such as DOM Elements) is just simply ignored.

Type

static

Parameters

objany object

Examples

Json.encode([true, null, 123, “456”, undefined, {‘foo’: ‘bar’}]);

Retruns

(String) JSON expression of the given object.

encodeArray

Json.encodeArray = function (obj)

Encode array into JSON String.  It will raise an error if the given object is not Array.

Type

static

Parameters

obj(Array)

Examples

Json.encodeArray([true, null, 123, “456”, undefined, {‘foo’: ‘bar’}]);

Retruns

(String) JSON expression of the given object.

encodeBoolean

Json.encodeBoolean = function (obj)

Encode boolean into JSON String.  It will raise an error if the given object is not Boolean.

Type

static

Parameters

obj(Boolean)

Examples

Json.encodeBoolean(true);

Retruns

(String) JSON expression of the given object.

encodeFunction

Json.encodeFunction = function (obj)

[FIX ME] Encode function into JSON String.  Hmm, i dunno how to do this.

Type

static

Parameters

obj(Function)

Examples

Json.encodeFunction(function(){});

Retruns

(String) JSON expression of the given object.

encodeNull

Json.encodeNull = function (obj)

Encode null into JSON String.  It will raise an error if the given object is not Null.

Type

static

Parameters

obj(Null)

Examples

Json.encodeNull(null);

Retruns

(String) JSON expression of the given object.

encodeNumber

Json.encodeNumber = function (obj)

Encode number into JSON String.  It will raise an error if the given object is not Number.

Type

static

Parameters

obj(Number)

Examples

Json.encodeNumber(123);

Retruns

(String) JSON expression of the given object.

encodeObject

Json.encodeObject = function (obj)

Encode object into JSON String.  It will raise an error if the given object is not Object.

Type

static

Parameters

obj(Object)

Examples

Json.encodeObject({‘foo’: ‘bar’});

Retruns

(String) JSON expression of the given object.

encodeString

Json.encodeString = function (obj)

Encode string into JSON String.  It will raise an error if the given object is not String.

Type

static

Parameters

obj(String)

Examples

Json.encodeString(‘foobar foo’);

Retruns

(String) JSON expression of the given object.

encodeUndefined

Json.encodeUndefined = function (obj)

Encode undefined into JSON String.  It will raise an error if the given object is not String.

Type

static

Parameters

obj(undefined)

Examples

Json.encodeUndefined(undefined);

Retruns

(String) JSON expression of the given object.

Json.encode = function (obj)
Dispatcher method for every JSON serialization.
Json.encodeArray = function (obj)
Encode array into JSON String.
Json.encodeBoolean = function (obj)
Encode boolean into JSON String.
Json.encodeFunction = function (obj)
[FIX ME] Encode function into JSON String.
Json.encodeNull = function (obj)
Encode null into JSON String.
Json.encodeNumber = function (obj)
Encode number into JSON String.
Json.encodeObject = function (obj)
Encode object into JSON String.
Json.encodeString = function (obj)
Encode string into JSON String.
Json.encodeUndefined = function (obj)
Encode undefined into JSON String.
Close