38 var a = [
'['], b, f, i, l = x.length, v;
39 for (i = 0; i < l; i += 1) {
44 if (typeof v ==
'string') {
56 'boolean':
function (x) {
59 'null':
function (x) {
62 number:
function (x) {
63 return isFinite(x) ? String(x) :
'null';
65 object:
function (x) {
67 if (x instanceof Array) {
70 var a = [
'{'], b, f, i, v;
76 if (typeof v ==
'string') {
80 a.push(s.string(i),
':', v);
90 string:
function (x) {
91 if (/[
"\\\x00-\x1f]/.test(x)) {
92 x = x.replace(/([\x00-\x1f\\"])/g,
function(a, b) {
99 Math.floor(c / 16).toString(16) +
100 (c % 16).toString(16);
103 return '"' + x +
'"';
107 Object.prototype.toJSONString =
function () {
108 return s.object(
this);
111 Array.prototype.toJSONString =
function () {
112 return s.array(
this);
116 String.prototype.parseJSON =
function () {
118 return (/^(
"(\\.|[^"\\\n\r])*?
"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this)) &&
119 eval('(' + this + ')');