app/json/json2.js
author Sverre Rabbelier <srabbelier@gmail.com>
Mon, 16 Mar 2009 23:52:49 +0000
changeset 1902 be3dbaa17114
parent 1731 254375a57d62
permissions -rw-r--r--
Added seed user to seed many Patch by: Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1731
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     1
/*
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     2
    http://www.JSON.org/json2.js
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     3
    2008-11-19
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     4
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     5
    Public Domain.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     6
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     7
    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     8
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     9
    See http://www.JSON.org/js.html
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    10
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    11
    This file creates a global JSON object containing two methods: stringify
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    12
    and parse.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    13
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    14
        JSON.stringify(value, replacer, space)
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    15
            value       any JavaScript value, usually an object or array.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    16
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    17
            replacer    an optional parameter that determines how object
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    18
                        values are stringified for objects. It can be a
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    19
                        function or an array of strings.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    20
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    21
            space       an optional parameter that specifies the indentation
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    22
                        of nested structures. If it is omitted, the text will
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    23
                        be packed without extra whitespace. If it is a number,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    24
                        it will specify the number of spaces to indent at each
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    25
                        level. If it is a string (such as '\t' or '&nbsp;'),
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    26
                        it contains the characters used to indent at each level.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    27
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    28
            This method produces a JSON text from a JavaScript value.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    29
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    30
            When an object value is found, if the object contains a toJSON
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    31
            method, its toJSON method will be called and the result will be
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    32
            stringified. A toJSON method does not serialize: it returns the
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    33
            value represented by the name/value pair that should be serialized,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    34
            or undefined if nothing should be serialized. The toJSON method
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    35
            will be passed the key associated with the value, and this will be
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    36
            bound to the object holding the key.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    37
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    38
            For example, this would serialize Dates as ISO strings.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    39
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    40
                Date.prototype.toJSON = function (key) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    41
                    function f(n) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    42
                        // Format integers to have at least two digits.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    43
                        return n < 10 ? '0' + n : n;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    44
                    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    45
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    46
                    return this.getUTCFullYear()   + '-' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    47
                         f(this.getUTCMonth() + 1) + '-' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    48
                         f(this.getUTCDate())      + 'T' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    49
                         f(this.getUTCHours())     + ':' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    50
                         f(this.getUTCMinutes())   + ':' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    51
                         f(this.getUTCSeconds())   + 'Z';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    52
                };
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    53
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    54
            You can provide an optional replacer method. It will be passed the
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    55
            key and value of each member, with this bound to the containing
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    56
            object. The value that is returned from your method will be
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    57
            serialized. If your method returns undefined, then the member will
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    58
            be excluded from the serialization.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    59
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    60
            If the replacer parameter is an array of strings, then it will be
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    61
            used to select the members to be serialized. It filters the results
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    62
            such that only members with keys listed in the replacer array are
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    63
            stringified.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    64
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    65
            Values that do not have JSON representations, such as undefined or
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    66
            functions, will not be serialized. Such values in objects will be
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    67
            dropped; in arrays they will be replaced with null. You can use
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    68
            a replacer function to replace those with JSON values.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    69
            JSON.stringify(undefined) returns undefined.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    70
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    71
            The optional space parameter produces a stringification of the
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    72
            value that is filled with line breaks and indentation to make it
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    73
            easier to read.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    74
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    75
            If the space parameter is a non-empty string, then that string will
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    76
            be used for indentation. If the space parameter is a number, then
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    77
            the indentation will be that many spaces.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    78
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    79
            Example:
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    80
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    81
            text = JSON.stringify(['e', {pluribus: 'unum'}]);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    82
            // text is '["e",{"pluribus":"unum"}]'
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    83
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    84
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    85
            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    86
            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    87
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    88
            text = JSON.stringify([new Date()], function (key, value) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    89
                return this[key] instanceof Date ?
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    90
                    'Date(' + this[key] + ')' : value;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    91
            });
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    92
            // text is '["Date(---current time---)"]'
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    93
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    94
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    95
        JSON.parse(text, reviver)
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    96
            This method parses a JSON text to produce an object or array.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    97
            It can throw a SyntaxError exception.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    98
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    99
            The optional reviver parameter is a function that can filter and
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   100
            transform the results. It receives each of the keys and values,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   101
            and its return value is used instead of the original value.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   102
            If it returns what it received, then the structure is not modified.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   103
            If it returns undefined then the member is deleted.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   104
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   105
            Example:
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   106
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   107
            // Parse the text. Values that look like ISO date strings will
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   108
            // be converted to Date objects.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   109
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   110
            myData = JSON.parse(text, function (key, value) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   111
                var a;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   112
                if (typeof value === 'string') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   113
                    a =
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   114
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   115
                    if (a) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   116
                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   117
                            +a[5], +a[6]));
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   118
                    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   119
                }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   120
                return value;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   121
            });
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   122
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   123
            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   124
                var d;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   125
                if (typeof value === 'string' &&
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   126
                        value.slice(0, 5) === 'Date(' &&
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   127
                        value.slice(-1) === ')') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   128
                    d = new Date(value.slice(5, -1));
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   129
                    if (d) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   130
                        return d;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   131
                    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   132
                }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   133
                return value;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   134
            });
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   135
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   136
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   137
    This is a reference implementation. You are free to copy, modify, or
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   138
    redistribute.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   139
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   140
    This code should be minified before deployment.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   141
    See http://javascript.crockford.com/jsmin.html
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   142
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   143
    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   144
    NOT CONTROL.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   145
*/
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   146
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   147
/*jslint evil: true */
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   148
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   149
/*global JSON */
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   150
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   151
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   152
    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   153
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   154
    lastIndex, length, parse, prototype, push, replace, slice, stringify,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   155
    test, toJSON, toString, valueOf
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   156
*/
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   157
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   158
// Create a JSON object only if one does not already exist. We create the
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   159
// methods in a closure to avoid creating global variables.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   160
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   161
if (!this.JSON) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   162
    JSON = {};
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   163
}
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   164
(function () {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   165
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   166
    function f(n) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   167
        // Format integers to have at least two digits.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   168
        return n < 10 ? '0' + n : n;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   169
    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   170
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   171
    if (typeof Date.prototype.toJSON !== 'function') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   172
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   173
        Date.prototype.toJSON = function (key) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   174
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   175
            return this.getUTCFullYear()   + '-' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   176
                 f(this.getUTCMonth() + 1) + '-' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   177
                 f(this.getUTCDate())      + 'T' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   178
                 f(this.getUTCHours())     + ':' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   179
                 f(this.getUTCMinutes())   + ':' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   180
                 f(this.getUTCSeconds())   + 'Z';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   181
        };
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   182
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   183
        String.prototype.toJSON =
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   184
        Number.prototype.toJSON =
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   185
        Boolean.prototype.toJSON = function (key) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   186
            return this.valueOf();
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   187
        };
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   188
    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   189
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   190
    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   191
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   192
        gap,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   193
        indent,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   194
        meta = {    // table of character substitutions
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   195
            '\b': '\\b',
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   196
            '\t': '\\t',
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   197
            '\n': '\\n',
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   198
            '\f': '\\f',
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   199
            '\r': '\\r',
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   200
            '"' : '\\"',
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   201
            '\\': '\\\\'
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   202
        },
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   203
        rep;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   204
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   205
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   206
    function quote(string) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   207
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   208
// If the string contains no control characters, no quote characters, and no
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   209
// backslash characters, then we can safely slap some quotes around it.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   210
// Otherwise we must also replace the offending characters with safe escape
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   211
// sequences.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   212
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   213
        escapable.lastIndex = 0;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   214
        return escapable.test(string) ?
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   215
            '"' + string.replace(escapable, function (a) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   216
                var c = meta[a];
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   217
                return typeof c === 'string' ? c :
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   218
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   219
            }) + '"' :
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   220
            '"' + string + '"';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   221
    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   222
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   223
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   224
    function str(key, holder) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   225
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   226
// Produce a string from holder[key].
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   227
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   228
        var i,          // The loop counter.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   229
            k,          // The member key.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   230
            v,          // The member value.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   231
            length,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   232
            mind = gap,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   233
            partial,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   234
            value = holder[key];
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   235
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   236
// If the value has a toJSON method, call it to obtain a replacement value.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   237
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   238
        if (value && typeof value === 'object' &&
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   239
                typeof value.toJSON === 'function') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   240
            value = value.toJSON(key);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   241
        }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   242
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   243
// If we were called with a replacer function, then call the replacer to
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   244
// obtain a replacement value.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   245
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   246
        if (typeof rep === 'function') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   247
            value = rep.call(holder, key, value);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   248
        }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   249
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   250
// What happens next depends on the value's type.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   251
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   252
        switch (typeof value) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   253
        case 'string':
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   254
            return quote(value);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   255
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   256
        case 'number':
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   257
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   258
// JSON numbers must be finite. Encode non-finite numbers as null.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   259
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   260
            return isFinite(value) ? String(value) : 'null';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   261
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   262
        case 'boolean':
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   263
        case 'null':
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   264
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   265
// If the value is a boolean or null, convert it to a string. Note:
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   266
// typeof null does not produce 'null'. The case is included here in
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   267
// the remote chance that this gets fixed someday.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   268
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   269
            return String(value);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   270
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   271
// If the type is 'object', we might be dealing with an object or an array or
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   272
// null.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   273
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   274
        case 'object':
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   275
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   276
// Due to a specification blunder in ECMAScript, typeof null is 'object',
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   277
// so watch out for that case.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   278
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   279
            if (!value) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   280
                return 'null';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   281
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   282
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   283
// Make an array to hold the partial results of stringifying this object value.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   284
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   285
            gap += indent;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   286
            partial = [];
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   287
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   288
// Is the value an array?
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   289
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   290
            if (Object.prototype.toString.apply(value) === '[object Array]') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   291
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   292
// The value is an array. Stringify every element. Use null as a placeholder
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   293
// for non-JSON values.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   294
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   295
                length = value.length;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   296
                for (i = 0; i < length; i += 1) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   297
                    partial[i] = str(i, value) || 'null';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   298
                }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   299
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   300
// Join all of the elements together, separated with commas, and wrap them in
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   301
// brackets.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   302
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   303
                v = partial.length === 0 ? '[]' :
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   304
                    gap ? '[\n' + gap +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   305
                            partial.join(',\n' + gap) + '\n' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   306
                                mind + ']' :
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   307
                          '[' + partial.join(',') + ']';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   308
                gap = mind;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   309
                return v;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   310
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   311
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   312
// If the replacer is an array, use it to select the members to be stringified.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   313
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   314
            if (rep && typeof rep === 'object') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   315
                length = rep.length;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   316
                for (i = 0; i < length; i += 1) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   317
                    k = rep[i];
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   318
                    if (typeof k === 'string') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   319
                        v = str(k, value);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   320
                        if (v) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   321
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   322
                        }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   323
                    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   324
                }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   325
            } else {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   326
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   327
// Otherwise, iterate through all of the keys in the object.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   328
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   329
                for (k in value) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   330
                    if (Object.hasOwnProperty.call(value, k)) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   331
                        v = str(k, value);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   332
                        if (v) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   333
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   334
                        }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   335
                    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   336
                }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   337
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   338
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   339
// Join all of the member texts together, separated with commas,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   340
// and wrap them in braces.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   341
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   342
            v = partial.length === 0 ? '{}' :
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   343
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   344
                        mind + '}' : '{' + partial.join(',') + '}';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   345
            gap = mind;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   346
            return v;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   347
        }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   348
    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   349
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   350
// If the JSON object does not yet have a stringify method, give it one.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   351
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   352
    if (typeof JSON.stringify !== 'function') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   353
        JSON.stringify = function (value, replacer, space) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   354
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   355
// The stringify method takes a value and an optional replacer, and an optional
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   356
// space parameter, and returns a JSON text. The replacer can be a function
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   357
// that can replace values, or an array of strings that will select the keys.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   358
// A default replacer method can be provided. Use of the space parameter can
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   359
// produce text that is more easily readable.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   360
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   361
            var i;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   362
            gap = '';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   363
            indent = '';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   364
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   365
// If the space parameter is a number, make an indent string containing that
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   366
// many spaces.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   367
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   368
            if (typeof space === 'number') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   369
                for (i = 0; i < space; i += 1) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   370
                    indent += ' ';
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   371
                }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   372
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   373
// If the space parameter is a string, it will be used as the indent string.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   374
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   375
            } else if (typeof space === 'string') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   376
                indent = space;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   377
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   378
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   379
// If there is a replacer, it must be a function or an array.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   380
// Otherwise, throw an error.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   381
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   382
            rep = replacer;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   383
            if (replacer && typeof replacer !== 'function' &&
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   384
                    (typeof replacer !== 'object' ||
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   385
                     typeof replacer.length !== 'number')) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   386
                throw new Error('JSON.stringify');
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   387
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   388
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   389
// Make a fake root object containing our value under the key of ''.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   390
// Return the result of stringifying the value.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   391
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   392
            return str('', {'': value});
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   393
        };
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   394
    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   395
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   396
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   397
// If the JSON object does not yet have a parse method, give it one.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   398
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   399
    if (typeof JSON.parse !== 'function') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   400
        JSON.parse = function (text, reviver) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   401
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   402
// The parse method takes a text and an optional reviver function, and returns
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   403
// a JavaScript value if the text is a valid JSON text.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   404
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   405
            var j;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   406
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   407
            function walk(holder, key) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   408
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   409
// The walk method is used to recursively walk the resulting structure so
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   410
// that modifications can be made.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   411
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   412
                var k, v, value = holder[key];
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   413
                if (value && typeof value === 'object') {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   414
                    for (k in value) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   415
                        if (Object.hasOwnProperty.call(value, k)) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   416
                            v = walk(value, k);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   417
                            if (v !== undefined) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   418
                                value[k] = v;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   419
                            } else {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   420
                                delete value[k];
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   421
                            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   422
                        }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   423
                    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   424
                }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   425
                return reviver.call(holder, key, value);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   426
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   427
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   428
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   429
// Parsing happens in four stages. In the first stage, we replace certain
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   430
// Unicode characters with escape sequences. JavaScript handles many characters
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   431
// incorrectly, either silently deleting them, or treating them as line endings.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   432
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   433
            cx.lastIndex = 0;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   434
            if (cx.test(text)) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   435
                text = text.replace(cx, function (a) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   436
                    return '\\u' +
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   437
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   438
                });
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   439
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   440
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   441
// In the second stage, we run the text against regular expressions that look
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   442
// for non-JSON patterns. We are especially concerned with '()' and 'new'
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   443
// because they can cause invocation, and '=' because it can cause mutation.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   444
// But just to be safe, we want to reject all unexpected forms.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   445
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   446
// We split the second stage into 4 regexp operations in order to work around
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   447
// crippling inefficiencies in IE's and Safari's regexp engines. First we
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   448
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   449
// replace all simple value tokens with ']' characters. Third, we delete all
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   450
// open brackets that follow a colon or comma or that begin the text. Finally,
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   451
// we look to see that the remaining characters are only whitespace or ']' or
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   452
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   453
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   454
            if (/^[\],:{}\s]*$/.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   455
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   456
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   457
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   458
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   459
// In the third stage we use the eval function to compile the text into a
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   460
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   461
// in JavaScript: it can begin a block or an object literal. We wrap the text
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   462
// in parens to eliminate the ambiguity.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   463
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   464
                j = eval('(' + text + ')');
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   465
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   466
// In the optional fourth stage, we recursively walk the new structure, passing
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   467
// each name/value pair to a reviver function for possible transformation.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   468
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   469
                return typeof reviver === 'function' ?
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   470
                    walk({'': j}, '') : j;
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   471
            }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   472
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   473
// If the text is not JSON parseable, then a SyntaxError is thrown.
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   474
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   475
            throw new SyntaxError('JSON.parse');
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   476
        };
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   477
    }
254375a57d62 Add json2.js to repository under json folder, update build script and app.yaml.template files.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   478
})();