Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15550 anikendra 1
/* Cassandra-compilant MAP v0.1.7 | Adapted by jcoc611 | Based on the following: */
2
/*! JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */
3
(function () {
4
	// Detect the `define` function exposed by asynchronous module loaders. The
5
	// strict `define` check is necessary for compatibility with `r.js`.
6
	var isLoader = typeof define === "function" && define.amd;
7
 
8
	// A set of types used to distinguish objects from primitives.
9
	var objectTypes = {
10
		"function": true,
11
		"object": true
12
	};
13
 
14
	// Detect the `exports` object exposed by CommonJS implementations.
15
	var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
16
 
17
	// Use the `global` object exposed by Node (including Browserify via
18
	// `insert-module-globals`), Narwhal, and Ringo as the default context,
19
	// and the `window` object in browsers. Rhino exports a `global` function
20
	// instead.
21
	var root = objectTypes[typeof window] && window || this,
22
			freeGlobal = freeExports && objectTypes[typeof module] && module && !module.nodeType && typeof global == "object" && global;
23
 
24
	if (freeGlobal && (freeGlobal["global"] === freeGlobal || freeGlobal["window"] === freeGlobal || freeGlobal["self"] === freeGlobal)) {
25
		root = freeGlobal;
26
	}
27
 
28
	// Public: Initializes JSON 3 using the given `context` object, attaching the
29
	// `stringify` and `parse` functions to the specified `exports` object.
30
	function runInContext(context, exports){
31
		context || (context = root["Object"]());
32
		exports || (exports = root["Object"]());
33
 
34
		// Native constructor aliases.
35
		var Number = context["Number"] || root["Number"],
36
				String = context["String"] || root["String"],
37
				Object = context["Object"] || root["Object"],
38
				Date = context["Date"] || root["Date"],
39
				SyntaxError = context["SyntaxError"] || root["SyntaxError"],
40
				TypeError = context["TypeError"] || root["TypeError"],
41
				Math = context["Math"] || root["Math"],
42
				nativeJSON = context["JSON"] || root["JSON"];
43
 
44
		// Delegate to the native `stringify` and `parse` implementations.
45
		if (typeof nativeJSON == "object" && nativeJSON) {
46
			exports.stringify = nativeJSON.stringify;
47
			exports.parse = nativeJSON.parse;
48
		}
49
 
50
		// Convenience aliases.
51
		var objectProto = Object.prototype,
52
				getClass = objectProto.toString,
53
				isProperty, forEach, undef;
54
 
55
		// Test the `Date#getUTC*` methods. Based on work by @Yaffle.
56
		var isExtended = new Date(-3509827334573292);
57
		try {	isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 && isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708}catch(exception){}
58
 
59
		// Internal: Determines whether the native `JSON.stringify` and `parse`
60
		// implementations are spec-compliant. Based on work by Ken Snyder.
61
		// Internal: Determines whether the native `JSON.stringify` and `parse`
62
		// implementations are spec-compliant. Based on work by Ken Snyder.
63
		function has(name) {
64
			if (has[name] !== undef) {
65
				// Return cached feature test result.
66
				return has[name];
67
			}
68
			var isSupported;
69
			if (name == "bug-string-char-index") {
70
				// IE <= 7 doesn't support accessing string characters using square
71
				// bracket notation. IE 8 only supports this for primitives.
72
				isSupported = "a"[0] != "a";
73
			// Do not use JSON as default.
74
			} else isSupported = false;
75
 
76
			return has[name] = !!isSupported;
77
		}
78
 
79
		// Common `[[Class]]` name aliases.
80
		var functionClass = "[object Function]",
81
				dateClass = "[object Date]",
82
				numberClass = "[object Number]",
83
				stringClass = "[object String]",
84
				arrayClass = "[object Array]",
85
				booleanClass = "[object Boolean]";
86
 
87
		// Detect incomplete support for accessing string characters by index.
88
		var charIndexBuggy = has("bug-string-char-index");
89
 
90
		// Define additional utility methods if the `Date` methods are buggy.
91
		if (!isExtended) {
92
			var floor = Math.floor;
93
			// A mapping between the months of the year and the number of days between
94
			// January 1st and the first of the respective month.
95
			var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
96
			// Internal: Calculates the number of days between the Unix epoch and the
97
			// first day of the given month.
98
			var getDay = function (year, month) {
99
				return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
100
			};
101
		}
102
 
103
		// Internal: Determines if a property is a direct property of the given
104
		// object. Delegates to the native `Object#hasOwnProperty` method.
105
		if (!(isProperty = objectProto.hasOwnProperty)) {
106
			isProperty = function (property) {
107
				var members = {}, constructor;
108
				if ((members.__proto__ = null, members.__proto__ = {
109
					// The *proto* property cannot be set multiple times in recent
110
					// versions of Firefox and SeaMonkey.
111
					"toString": 1
112
				}, members).toString != getClass) {
113
					// Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but
114
					// supports the mutable *proto* property.
115
					isProperty = function (property) {
116
						// Capture and break the object's prototype chain (see section 8.6.2
117
						// of the ES 5.1 spec). The parenthesized expression prevents an
118
						// unsafe transformation by the Closure Compiler.
119
						var original = this.__proto__, result = property in (this.__proto__ = null, this);
120
						// Restore the original prototype chain.
121
						this.__proto__ = original;
122
						return result;
123
					};
124
				} else {
125
					// Capture a reference to the top-level `Object` constructor.
126
					constructor = members.constructor;
127
					// Use the `constructor` property to simulate `Object#hasOwnProperty` in
128
					// other environments.
129
					isProperty = function (property) {
130
						var parent = (this.constructor || constructor).prototype;
131
						return property in this && !(property in parent && this[property] === parent[property]);
132
					};
133
				}
134
				members = null;
135
				return isProperty.call(this, property);
136
			};
137
		}
138
 
139
		// Internal: Normalizes the `for...in` iteration algorithm across
140
		// environments. Each enumerated key is yielded to a `callback` function.
141
		forEach = function (object, callback) {
142
			var size = 0, Properties, members, property;
143
 
144
			// Tests for bugs in the current environment's `for...in` algorithm. The
145
			// `valueOf` property inherits the non-enumerable flag from
146
			// `Object.prototype` in older versions of IE, Netscape, and Mozilla.
147
			(Properties = function () {
148
				this.valueOf = 0;
149
			}).prototype.valueOf = 0;
150
 
151
			// Iterate over a new instance of the `Properties` class.
152
			members = new Properties();
153
			for (property in members) {
154
				// Ignore all properties inherited from `Object.prototype`.
155
				if (isProperty.call(members, property)) {
156
					size++;
157
				}
158
			}
159
			Properties = members = null;
160
 
161
			// Normalize the iteration algorithm.
162
			if (!size) {
163
				// A list of non-enumerable properties inherited from `Object.prototype`.
164
				members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
165
				// IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable
166
				// properties.
167
				forEach = function (object, callback) {
168
					var isFunction = getClass.call(object) == functionClass, property, length;
169
					var hasProperty = !isFunction && typeof object.constructor != "function" && objectTypes[typeof object.hasOwnProperty] && object.hasOwnProperty || isProperty;
170
					for (property in object) {
171
						// Gecko <= 1.0 enumerates the `prototype` property of functions under
172
						// certain conditions; IE does not.
173
						if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) {
174
							callback(property);
175
						}
176
					}
177
					// Manually invoke the callback for each non-enumerable property.
178
					for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property));
179
				};
180
			} else if (size == 2) {
181
				// Safari <= 2.0.4 enumerates shadowed properties twice.
182
				forEach = function (object, callback) {
183
					// Create a set of iterated properties.
184
					var members = {}, isFunction = getClass.call(object) == functionClass, property;
185
					for (property in object) {
186
						// Store each property name to prevent double enumeration. The
187
						// `prototype` property of functions is not enumerated due to cross-
188
						// environment inconsistencies.
189
						if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
190
							callback(property);
191
						}
192
					}
193
				};
194
			} else {
195
				// No bugs detected; use the standard `for...in` algorithm.
196
				forEach = function (object, callback) {
197
					var isFunction = getClass.call(object) == functionClass, property, isConstructor;
198
					for (property in object) {
199
						if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
200
							callback(property);
201
						}
202
					}
203
					// Manually invoke the callback for the `constructor` property due to
204
					// cross-environment inconsistencies.
205
					if (isConstructor || isProperty.call(object, (property = "constructor"))) {
206
						callback(property);
207
					}
208
				};
209
			}
210
			return forEach(object, callback);
211
		};
212
 
213
		// Public: Serializes a JavaScript `value` as a JSON string. The optional
214
		// `filter` argument may specify either a function that alters how object and
215
		// array members are serialized, or an array of strings and numbers that
216
		// indicates which properties should be serialized. The optional `width`
217
		// argument may be either a string or number that specifies the indentation
218
		// level of the output.
219
 
220
		// Internal: A map of control characters and their escaped equivalents.
221
		// [Cassandra]: uses single quotes.
222
		var Escapes = {
223
			92: "\\\\",
224
			//34: '\\" ',
225
			39: "\\'", // single quote escape
226
			8: "\\b",
227
			12: "\\f",
228
			10: "\\n",
229
			13: "\\r",
230
			9: "\\t"
231
		};
232
 
233
		// Internal: Converts `value` into a zero-padded string such that its
234
		// length is at least equal to `width`. The `width` must be <= 6.
235
		var leadingZeroes = "000000";
236
		var toPaddedString = function (width, value) {
237
			// The `|| 0` expression is necessary to work around a bug in
238
			// Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.
239
			return (leadingZeroes + (value || 0)).slice(-width);
240
		};
241
 
242
		// Internal: Double-quotes a string `value`, replacing all ASCII control
243
		// characters (characters with code unit values between 0 and 31) with
244
		// their escaped equivalents. This is an implementation of the
245
		// `Quote(value)` operation defined in ES 5.1 section 15.12.3.
246
		var unicodePrefix = "\\u00";
247
		var quote = function (value) {
248
			var result = "'", index = 0, length = value.length, useCharIndex = !charIndexBuggy || length > 10;
249
			var symbols = useCharIndex && (charIndexBuggy ? value.split("") : value);
250
			for (; index < length; index++) {
251
				var charCode = value.charCodeAt(index);
252
				// If the character is a control character, append its Unicode or
253
				// shorthand escape sequence; otherwise, append the character as-is.
254
				switch (charCode) {
255
					case 8: case 9: case 10: case 12: case 13: case 39: case 92:
256
						result += Escapes[charCode];
257
						break;
258
					default:
259
						if (charCode < 32) {
260
							result += unicodePrefix + toPaddedString(2, charCode.toString(16));
261
							break;
262
						}
263
						result += useCharIndex ? symbols[index] : value.charAt(index);
264
				}
265
			}
266
			return result + "'";
267
		};
268
 
269
		// Internal: Recursively serializes an object. Implements the
270
		// `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.
271
		var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
272
			var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, result;
273
			try {
274
				// Necessary for host object support.
275
				value = object[property];
276
			} catch (exception) {}
277
			if (typeof value == "object" && value) {
278
				className = getClass.call(value);
279
				if (className == dateClass && !isProperty.call(value, "toJSON")) {
280
					if (value > -1 / 0 && value < 1 / 0) {
281
						// Dates are serialized according to the `Date#toJSON` method
282
						// specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
283
						// for the ISO 8601 date time string format.
284
						if (getDay) {
285
							// Manually compute the year, month, date, hours, minutes,
286
							// seconds, and milliseconds if the `getUTC*` methods are
287
							// buggy. Adapted from @Yaffle's `date-shim` project.
288
							date = floor(value / 864e5);
289
							for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
290
							for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
291
							date = 1 + date - getDay(year, month);
292
							// The `time` value specifies the time within the day (see ES
293
							// 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used
294
							// to compute `A modulo B`, as the `%` operator does not
295
							// correspond to the `modulo` operation for negative numbers.
296
							time = (value % 864e5 + 864e5) % 864e5;
297
							// The hours, minutes, seconds, and milliseconds are obtained by
298
							// decomposing the time within the day. See section 15.9.1.10.
299
							hours = floor(time / 36e5) % 24;
300
							minutes = floor(time / 6e4) % 60;
301
							seconds = floor(time / 1e3) % 60;
302
							milliseconds = time % 1e3;
303
						} else {
304
							year = value.getUTCFullYear();
305
							month = value.getUTCMonth();
306
							date = value.getUTCDate();
307
							hours = value.getUTCHours();
308
							minutes = value.getUTCMinutes();
309
							seconds = value.getUTCSeconds();
310
							milliseconds = value.getUTCMilliseconds();
311
						}
312
						// Serialize extended years correctly.
313
						value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
314
							"-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
315
							// Months, dates, hours, minutes, and seconds should have two
316
							// digits; milliseconds should have three.
317
							"T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
318
							// Milliseconds are optional in ES 5.0, but required in 5.1.
319
							"." + toPaddedString(3, milliseconds) + "Z";
320
					} else {
321
						value = null;
322
					}
323
				} else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) {
324
					// Prototype <= 1.6.1 adds non-standard `toJSON` methods to the
325
					// `Number`, `String`, `Date`, and `Array` prototypes. JSON 3
326
					// ignores all `toJSON` methods on these objects unless they are
327
					// defined directly on an instance.
328
					value = value.toJSON(property);
329
				}
330
			}
331
			if (callback) {
332
				// If a replacement function was provided, call it to obtain the value
333
				// for serialization.
334
				value = callback.call(object, property, value);
335
			}
336
			if (value === null) {
337
				return "null";
338
			}
339
			className = getClass.call(value);
340
			if (className == booleanClass) {
341
				// Booleans are represented literally.
342
				return "" + value;
343
			} else if (className == numberClass) {
344
				// JSON numbers must be finite. `Infinity` and `NaN` are serialized as
345
				// `"null"`.
346
				return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
347
			} else if (className == stringClass) {
348
				// Strings are double-quoted and escaped.
349
				return quote("" + value);
350
			}
351
			// Recursively serialize objects and arrays.
352
			if (typeof value == "object") {
353
				// Check for cyclic structures. This is a linear search; performance
354
				// is inversely proportional to the number of unique nested objects.
355
				for (length = stack.length; length--;) {
356
					if (stack[length] === value) {
357
						// Cyclic structures cannot be serialized by `JSON.stringify`.
358
						throw TypeError();
359
					}
360
				}
361
				// Add the object to the stack of traversed objects.
362
				stack.push(value);
363
				results = [];
364
				// Save the current indentation level and indent one additional level.
365
				prefix = indentation;
366
				indentation += whitespace;
367
				if (className == arrayClass) {
368
					// Recursively serialize array elements.
369
					for (index = 0, length = value.length; index < length; index++) {
370
						element = serialize(index, value, callback, properties, whitespace, indentation, stack);
371
						results.push(element === undef ? "null" : element);
372
					}
373
					result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
374
				} else {
375
					// Recursively serialize object members. Members are selected from
376
					// either a user-specified list of property names, or the object
377
					// itself.
378
					forEach(properties || value, function (property) {
379
						var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
380
						if (element !== undef) {
381
							// According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
382
							// is not the empty string, let `member` {quote(property) + ":"}
383
							// be the concatenation of `member` and the `space` character."
384
							// The "`space` character" refers to the literal space
385
							// character, not the `space` {width} argument provided to
386
							// `JSON.stringify`.
387
							results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
388
						}
389
					});
390
					result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
391
				}
392
				// Remove the object from the traversed object stack.
393
				stack.pop();
394
				return result;
395
			}
396
		};
397
 
398
		// Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
399
		exports.stringify = function (source, filter, width) {
400
			var whitespace, callback, properties, className;
401
			if (objectTypes[typeof filter] && filter) {
402
				if ((className = getClass.call(filter)) == functionClass) {
403
					callback = filter;
404
				} else if (className == arrayClass) {
405
					// Convert the property names array into a makeshift set.
406
					properties = {};
407
					for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((className = getClass.call(value)), className == stringClass || className == numberClass) && (properties[value] = 1));
408
				}
409
			}
410
			if (width) {
411
				if ((className = getClass.call(width)) == numberClass) {
412
					// Convert the `width` to an integer and create a string containing
413
					// `width` number of space characters.
414
					if ((width -= width % 1) > 0) {
415
						for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
416
					}
417
				} else if (className == stringClass) {
418
					whitespace = width.length <= 10 ? width : width.slice(0, 10);
419
				}
420
			}
421
			// Opera <= 7.54u2 discards the values associated with empty string keys
422
			// (`""`) only if they are used directly within an object member list
423
			// (e.g., `!("" in { "": 1})`).
424
			return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
425
		};
426
 
427
 
428
		// Public: Parses a JSON source string.
429
		var fromCharCode = String.fromCharCode;
430
 
431
		// Internal: A map of escaped control characters and their unescaped
432
		// equivalents.
433
		var Unescapes = {
434
			92: "\\",
435
			// 34: '"',
436
			39: "'", // single quote
437
			47: "/",
438
			98: "\b",
439
			116: "\t",
440
			110: "\n",
441
			102: "\f",
442
			114: "\r"
443
		};
444
 
445
		// Internal: Stores the parser state.
446
		var Index, Source;
447
 
448
		// Internal: Resets the parser state and throws a `SyntaxError`.
449
		var abort = function () {
450
			Index = Source = null;
451
			throw SyntaxError();
452
		};
453
 
454
		// Internal: Returns the next token, or `"$"` if the parser has reached
455
		// the end of the source string. A token may be a string, number, `null`
456
		// literal, or Boolean literal.
457
		var lex = function () {
458
			var source = Source, length = source.length, value, begin, position, isSigned, charCode;
459
			while (Index < length) {
460
				charCode = source.charCodeAt(Index);
461
				switch (charCode) {
462
					case 9: case 10: case 13: case 32:
463
						// Skip whitespace tokens, including tabs, carriage returns, line
464
						// feeds, and space characters.
465
						Index++;
466
						break;
467
					case 123: case 125: case 91: case 93: case 58: case 44:
468
						// Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at
469
						// the current position.
470
						value = charIndexBuggy ? source.charAt(Index) : source[Index];
471
						Index++;
472
						return value;
473
					case 39:
474
						// `'` delimits a MAP string; advance to the next character and
475
						// begin parsing the string. String tokens are prefixed with the
476
						// sentinel `@` character to distinguish them from punctuators and
477
						// end-of-string tokens.
478
						for (value = "@", Index++; Index < length;) {
479
							charCode = source.charCodeAt(Index);
480
							if (charCode < 32) {
481
								// Unescaped ASCII control characters (those with a code unit
482
								// less than the space character) are not permitted.
483
								abort();
484
							} else if (charCode == 92) {
485
								// A reverse solidus (`\`) marks the beginning of an escaped
486
								// control character (including `"`, `\`, and `/`) or Unicode
487
								// escape sequence.
488
								charCode = source.charCodeAt(++Index);
489
								switch (charCode) {
490
									case 92: case 39: case 47: case 98: case 116: case 110: case 102: case 114:
491
										// Revive escaped control characters.
492
										value += Unescapes[charCode];
493
										Index++;
494
										break;
495
									case 117:
496
										// `\u` marks the beginning of a Unicode escape sequence.
497
										// Advance to the first character and validate the
498
										// four-digit code point.
499
										begin = ++Index;
500
										for (position = Index + 4; Index < position; Index++) {
501
											charCode = source.charCodeAt(Index);
502
											// A valid sequence comprises four hexdigits (case-
503
											// insensitive) that form a single hexadecimal value.
504
											if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {
505
												// Invalid Unicode escape sequence.
506
												abort();
507
											}
508
										}
509
										// Revive the escaped character.
510
										value += fromCharCode("0x" + source.slice(begin, Index));
511
										break;
512
									default:
513
										// Invalid escape sequence.
514
										abort();
515
								}
516
							} else {
517
								if (charCode == 39) {
518
									// An unescaped double-quote character marks the end of the
519
									// string.
520
									break;
521
								}
522
								charCode = source.charCodeAt(Index);
523
								begin = Index;
524
								// Optimize for the common case where a string is valid.
525
								while (charCode >= 32 && charCode != 92 && charCode != 39) {
526
									charCode = source.charCodeAt(++Index);
527
								}
528
								// Append the string as-is.
529
								value += source.slice(begin, Index);
530
							}
531
						}
532
						if (source.charCodeAt(Index) == 39) {
533
							// Advance to the next character and return the revived string.
534
							Index++;
535
							return value;
536
						}
537
						// Unterminated string.
538
						abort();
539
					default:
540
						// Parse numbers and literals.
541
						begin = Index;
542
						// Advance past the negative sign, if one is specified.
543
						if (charCode == 45) {
544
							isSigned = true;
545
							charCode = source.charCodeAt(++Index);
546
						}
547
						// Parse an integer or floating-point value.
548
						if (charCode >= 48 && charCode <= 57) {
549
							// Leading zeroes are interpreted as octal literals.
550
							if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {
551
								// Illegal octal literal.
552
								abort();
553
							}
554
							isSigned = false;
555
							// Parse the integer component.
556
							for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++);
557
							// Floats cannot contain a leading decimal point; however, this
558
							// case is already accounted for by the parser.
559
							if (source.charCodeAt(Index) == 46) {
560
								position = ++Index;
561
								// Parse the decimal component.
562
								for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
563
								if (position == Index) {
564
									// Illegal trailing decimal.
565
									abort();
566
								}
567
								Index = position;
568
							}
569
							// Parse exponents. The `e` denoting the exponent is
570
							// case-insensitive.
571
							charCode = source.charCodeAt(Index);
572
							if (charCode == 101 || charCode == 69) {
573
								charCode = source.charCodeAt(++Index);
574
								// Skip past the sign following the exponent, if one is
575
								// specified.
576
								if (charCode == 43 || charCode == 45) {
577
									Index++;
578
								}
579
								// Parse the exponential component.
580
								for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
581
								if (position == Index) {
582
									// Illegal empty exponent.
583
									abort();
584
								}
585
								Index = position;
586
							}
587
							// Coerce the parsed value to a JavaScript number.
588
							return +source.slice(begin, Index);
589
						}
590
						// A negative sign may only precede numbers.
591
						if (isSigned) {
592
							abort();
593
						}
594
						// `true`, `false`, and `null` literals.
595
						if (source.slice(Index, Index + 4) == "true") {
596
							Index += 4;
597
							return true;
598
						} else if (source.slice(Index, Index + 5) == "false") {
599
							Index += 5;
600
							return false;
601
						} else if (source.slice(Index, Index + 4) == "null") {
602
							Index += 4;
603
							return null;
604
						}
605
						// Unrecognized token.
606
						abort();
607
				}
608
			}
609
			// Return the sentinel `$` character if the parser has reached the end
610
			// of the source string.
611
			return "$";
612
		};
613
 
614
		// Internal: Parses a JSON `value` token.
615
		var get = function (value) {
616
			var results, hasMembers;
617
			if (value == "$") {
618
				// Unexpected end of input.
619
				abort();
620
			}
621
			if (typeof value == "string") {
622
				if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") {
623
					// Remove the sentinel `@` character.
624
					return value.slice(1);
625
				}
626
				// Parse object and array literals.
627
				if (value == "[") {
628
					// Parses a JSON array, returning a new JavaScript array.
629
					results = [];
630
					for (;; hasMembers || (hasMembers = true)) {
631
						value = lex();
632
						// A closing square bracket marks the end of the array literal.
633
						if (value == "]") {
634
							break;
635
						}
636
						// If the array literal contains elements, the current token
637
						// should be a comma separating the previous element from the
638
						// next.
639
						if (hasMembers) {
640
							if (value == ",") {
641
								value = lex();
642
								if (value == "]") {
643
									// Unexpected trailing `,` in array literal.
644
									abort();
645
								}
646
							} else {
647
								// A `,` must separate each array element.
648
								abort();
649
							}
650
						}
651
						// Elisions and leading commas are not permitted.
652
						if (value == ",") {
653
							abort();
654
						}
655
						results.push(get(value));
656
					}
657
					return results;
658
				} else if (value == "{") {
659
					// Parses a JSON object, returning a new JavaScript object.
660
					results = {};
661
					for (;; hasMembers || (hasMembers = true)) {
662
						value = lex();
663
						// A closing curly brace marks the end of the object literal.
664
						if (value == "}") {
665
							break;
666
						}
667
						// If the object literal contains members, the current token
668
						// should be a comma separator.
669
						if (hasMembers) {
670
							if (value == ",") {
671
								value = lex();
672
								if (value == "}") {
673
									// Unexpected trailing `,` in object literal.
674
									abort();
675
								}
676
							} else {
677
								// A `,` must separate each object member.
678
								abort();
679
							}
680
						}
681
						// Leading commas are not permitted, object property names must be
682
						// double-quoted strings, and a `:` must separate each property
683
						// name and value.
684
						if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") {
685
							abort();
686
						}
687
						results[value.slice(1)] = get(lex());
688
					}
689
					return results;
690
				}
691
				// Unexpected token encountered.
692
				abort();
693
			}
694
			return value;
695
		};
696
 
697
		// Internal: Updates a traversed object member.
698
		var update = function (source, property, callback) {
699
			var element = walk(source, property, callback);
700
			if (element === undef) {
701
				delete source[property];
702
			} else {
703
				source[property] = element;
704
			}
705
		};
706
 
707
		// Internal: Recursively traverses a parsed JSON object, invoking the
708
		// `callback` function for each value. This is an implementation of the
709
		// `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
710
		var walk = function (source, property, callback) {
711
			var value = source[property], length;
712
			if (typeof value == "object" && value) {
713
				// `forEach` can't be used to traverse an array in Opera <= 8.54
714
				// because its `Object#hasOwnProperty` implementation returns `false`
715
				// for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`).
716
				if (getClass.call(value) == arrayClass) {
717
					for (length = value.length; length--;) {
718
						update(value, length, callback);
719
					}
720
				} else {
721
					forEach(value, function (property) {
722
						update(value, property, callback);
723
					});
724
				}
725
			}
726
			return callback.call(source, property, value);
727
		};
728
 
729
		// Public: `JSON.parse`. See ES 5.1 section 15.12.2.
730
		exports.parse = function (source, callback) {
731
			var result, value;
732
			Index = 0;
733
			Source = "" + source;
734
			result = get(lex());
735
			// If a JSON string contains multiple tokens, it is invalid.
736
			if (lex() != "$") {
737
				abort();
738
			}
739
			// Reset the parser state.
740
			Index = Source = null;
741
			return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;
742
		};	
743
 
744
		exports["runInContext"] = runInContext;
745
		return exports;
746
	};
747
	// Creates an object and returns it with the .stringify, .parse, and .runInContext
748
	root["cassandraMAP"] = {};
749
	runInContext(root, freeExports||root["cassandraMAP"]);
750
 
751
}).call(this);