2
Copyright (c) 2005 JSON.org
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
11
The Software shall be used for Good, not Evil.
13
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
//Array.prototype.______array = '______array';
25
org: 'http://www.JSON.org',
26
copyright: '(c)2005 JSON.org',
27
license: 'http://www.crockford.com/JSON/license.html',
29
stringify: function (arg) {
30
var c, i, l, s = '', v;
35
if (arg.constructor == Array.prototype.constructor) {
36
for (i = 0; i < arg.length; ++i) {
37
v = this.stringify(arg[i]);
44
} else if (typeof arg.toString != 'undefined') {
47
if (typeof v != 'undefined' && typeof v != 'function') {
48
v = this.stringify(v);
52
s += this.stringify(i) + ':' + v;
60
return isFinite(arg) ? String(arg) : 'null';
64
for (i = 0; i < l; i += 1) {
67
if (c == '\\' || c == '"') {
90
s += '\\u00' + Math.floor(c / 16).toString(16) +
91
(c % 16).toString(16);
102
parse: function (text) {
116
ch = text.charAt(at);
125
} else if (ch == '/') {
128
while (next() && ch != '\n' && ch != '\r') {}
143
error("Unterminated comment");
148
error("Syntax error");
160
outer: while (next()) {
164
} else if (ch == '\\') {
183
for (i = 0; i < 4; i += 1) {
184
t = parseInt(next(), 16);
190
s += String.fromCharCode(u);
219
} else if (ch != ',') {
251
} else if (ch != ',') {
267
while (ch >= '0' && ch <= '9') {
273
while (next() && ch >= '0' && ch <= '9') {
277
if (ch == 'e' || ch == 'E') {
280
if (ch == '-' || ch == '+') {
284
while (ch >= '0' && ch <= '9') {
291
////error("Bad number");
300
if (next() == 'r' && next() == 'u' && next() == 'e') {
306
if (next() == 'a' && next() == 'l' && next() == 's' &&
313
if (next() == 'u' && next() == 'l' && next() == 'l') {
319
error("Syntax error");
334
return ch >= '0' && ch <= '9' ? number() : word();