json.js

Implements two crucial JSON functions.


Functions


OAT.JSON.parse(string)

Parses JSON string.

OAT.JSON.stringify(variable, [maxDepth])

Returns JSON representation of variable. The maxDepth argument specifies maximum depth for recursive structures; -1 signifies no depth limit.

Cyclic structures are detected and safely interrupted, but could not be further restored.

var a = {x:"y", number:123};
var b = OAT.JSON.stringify(a,-1);
var c = OAT.JSON.parse(b); // c now equals a