1/** The JSON class is copyright 2005 JSON.org. */ 2Array.prototype.______array = '______array'; 3 4var rshJSON = { 5 org: 'http://www.JSON.org', 6 copyright: '(c)2005 JSON.org', 7 license: 'http://www.crockford.com/JSON/license.html', 8 9 stringify: function (arg) { 10 var c, i, l, s = '', v; 11 12 switch (typeof arg) { 13 case 'object': 14 if (arg) { 15 if (arg.______array == '______array') { 16 for (i = 0; i < arg.length; ++i) { 17 v = this.stringify(arg[i]); 18 if (s) { 19 s += ','; 20 } 21 s += v; 22 } 23 return '[' + s + ']'; 24 } else if (typeof arg.toString != 'undefined') { 25 for (i in arg) { 26 v = arg[i]; 27 if (typeof v != 'undefined' && typeof v != 'function') { 28 v = this.stringify(v); 29 if (s) { 30 s += ','; 31 } 32 s += this.stringify(i) + ':' + v; 33 } 34 } 35 return '{' + s + '}'; 36 } 37 } 38 return 'null'; 39 case 'number': 40 return isFinite(arg) ? String(arg) : 'null'; 41 case 'string': 42 l = arg.length; 43 s = '"'; 44 for (i = 0; i < l; i += 1) { 45 c = arg.charAt(i); 46 if (c >= ' ') { 47 if (c == '\\' || c == '"') { 48 s += '\\'; 49 } 50 s += c; 51 } else { 52 switch (c) { 53 case '\b': 54 s += '\\b'; 55 break; 56 case '\f': 57 s += '\\f'; 58 break; 59 case '\n': 60 s += '\\n'; 61 break; 62 case '\r': 63 s += '\\r'; 64 break; 65 case '\t': 66 s += '\\t'; 67 break; 68 default: 69 c = c.charCodeAt(); 70 s += '\\u00' + Math.floor(c / 16).toString(16) + 71 (c % 16).toString(16); 72 } 73 } 74 } 75 return s + '"'; 76 case 'boolean': 77 return String(arg); 78 default: 79 return 'null'; 80 } 81 }, 82 parse: function (text) { 83 var at = 0; 84 var ch = ' '; 85 86 function error(m) { 87 throw { 88 name: 'JSONError', 89 message: m, 90 at: at - 1, 91 text: text 92 }; 93 } 94 95 function next() { 96 ch = text.charAt(at); 97 at += 1; 98 return ch; 99 } 100 101 function white() { 102 while (ch != '' && ch <= ' ') { 103 next(); 104 } 105 } 106 107 function str() { 108 var i, s = '', t, u; 109 110 if (ch == '"') { 111outer: while (next()) { 112 if (ch == '"') { 113 next(); 114 return s; 115 } else if (ch == '\\') { 116 switch (next()) { 117 case 'b': 118 s += '\b'; 119 break; 120 case 'f': 121 s += '\f'; 122 break; 123 case 'n': 124 s += '\n'; 125 break; 126 case 'r': 127 s += '\r'; 128 break; 129 case 't': 130 s += '\t'; 131 break; 132 case 'u': 133 u = 0; 134 for (i = 0; i < 4; i += 1) { 135 t = parseInt(next(), 16); 136 if (!isFinite(t)) { 137 break outer; 138 } 139 u = u * 16 + t; 140 } 141 s += String.fromCharCode(u); 142 break; 143 default: 144 s += ch; 145 } 146 } else { 147 s += ch; 148 } 149 } 150 } 151 error("Bad string"); 152 } 153 154 function arr() { 155 var a = []; 156 157 if (ch == '[') { 158 next(); 159 white(); 160 if (ch == ']') { 161 next(); 162 return a; 163 } 164 while (ch) { 165 a.push(val()); 166 white(); 167 if (ch == ']') { 168 next(); 169 return a; 170 } else if (ch != ',') { 171 break; 172 } 173 next(); 174 white(); 175 } 176 } 177 error("Bad array"); 178 } 179 180 function obj() { 181 var k, o = {}; 182 183 if (ch == '{') { 184 next(); 185 white(); 186 if (ch == '}') { 187 next(); 188 return o; 189 } 190 while (ch) { 191 k = str(); 192 white(); 193 if (ch != ':') { 194 break; 195 } 196 next(); 197 o[k] = val(); 198 white(); 199 if (ch == '}') { 200 next(); 201 return o; 202 } else if (ch != ',') { 203 break; 204 } 205 next(); 206 white(); 207 } 208 } 209 error("Bad object"); 210 } 211 212 function num() { 213 var n = '', v; 214 if (ch == '-') { 215 n = '-'; 216 next(); 217 } 218 while (ch >= '0' && ch <= '9') { 219 n += ch; 220 next(); 221 } 222 if (ch == '.') { 223 n += '.'; 224 while (next() && ch >= '0' && ch <= '9') { 225 n += ch; 226 } 227 } 228 if (ch == 'e' || ch == 'E') { 229 n += 'e'; 230 next(); 231 if (ch == '-' || ch == '+') { 232 n += ch; 233 next(); 234 } 235 while (ch >= '0' && ch <= '9') { 236 n += ch; 237 next(); 238 } 239 } 240 v = +n; 241 if (!isFinite(v)) { 242 error("Bad number"); 243 } else { 244 return v; 245 } 246 } 247 248 function word() { 249 switch (ch) { 250 case 't': 251 if (next() == 'r' && next() == 'u' && next() == 'e') { 252 next(); 253 return true; 254 } 255 break; 256 case 'f': 257 if (next() == 'a' && next() == 'l' && next() == 's' && 258 next() == 'e') { 259 next(); 260 return false;
261 } 262 break; 263 case 'n': 264 if (next() == 'u' && next() == 'l' && next() == 'l') { 265 next(); 266 return null; 267 } 268 break; 269 } 270 error("Syntax error"); 271 } 272 273 function val() { 274 white(); 275 switch (ch) { 276 case '{': 277 return obj(); 278 case '[': 279 return arr(); 280 case '"': 281 return str(); 282 case '-': 283 return num(); 284 default: 285 return ch >= '0' && ch <= '9' ? num() : word(); 286 } 287 } 288 289 return val(); 290 } 291};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.