jquery.json = { usehasown: ({}.hasownproperty ? true : false), pad: function (n) { return n < 10 ? "0" + n : n; }, m: { "\b": '\\b', "\t": '\\t', "\n": '\\n', "\f": '\\f', "\r": '\\r', '"': '\\"', "\\": '\\\\' }, encodestring: function (s) { if (/["\\\x00-\x1f]/.test(s)) { return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { var c = $.json.m[b]; if (c) { return c; } c = b.charcodeat(); return "\\u00" + math.floor(c / 16).tostring(16) + (c % 16).tostring(16); }) + '"'; } return '"' + s + '"'; }, encodearray: function (o) { var a = ["["], b, i, l = o.length, v; for (i = 0; i < l; i += 1) { v = o[i]; switch (typeof v) { case "undefined": case "function": case "unknown": break; default: if (b) { a.push(','); } a.push(v === null ? "null" : this.encode(v)); b = true; } } a.push("]"); return a.join(""); }, encodedate: function (o) { return '"' + o.getfullyear() + "-" + pad(o.getmonth() + 1) + "-" + pad(o.getdate()) + "t" + pad(o.gethours()) + ":" + pad(o.getminutes()) + ":" + pad(o.getseconds()) + '"'; }, encode: function (o) { if (typeof o == "undefined" || o === null) { return "null"; } else if (o instanceof array) { return this.encodearray(o); } else if (o instanceof date) { return this.encodedate(o); } else if (typeof o == "string") { return this.encodestring(o); } else if (typeof o == "number") { return isfinite(o) ? string(o) : "null"; } else if (typeof o == "boolean") { return string(o); } else { var self = this; var a = ["{"], b, i, v; for (i in o) { if (!this.usehasown || o.hasownproperty(i)) { v = o[i]; switch (typeof v) { case "undefined": case "function": case "unknown": break; default: if (b) { a.push(','); } a.push(self.encode(i), ":", v === null ? "null" : self.encode(v)); b = true; } } } a.push("}"); return a.join(""); } }, decode: function (json) { return eval("(" + json + ')'); } };