json 1.5.3-java → 1.5.4-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of json might be problematic. Click here for more details.
- data/lib/json.rb +7 -7
- data/lib/json/add/complex.rb +22 -0
- data/lib/json/add/core.rb +9 -9
- data/lib/json/add/rational.rb +22 -0
- data/lib/json/common.rb +50 -38
- data/lib/json/editor.rb +16 -16
- data/lib/json/ext.rb +2 -15
- data/lib/json/ext/generator.jar +0 -0
- data/lib/json/ext/parser.jar +0 -0
- data/lib/json/pure/generator.rb +18 -3
- data/lib/json/pure/parser.rb +92 -58
- data/lib/json/version.rb +1 -1
- data/tests/test_json.rb +52 -1
- data/tests/test_json_addition.rb +9 -2
- data/tests/test_json_generate.rb +34 -1
- metadata +47 -54
- data/lib/json/add/rails.rb +0 -8
    
        data/lib/json.rb
    CHANGED
    
    | @@ -7,15 +7,15 @@ | |
| 7 7 | 
             
            #
         | 
| 8 8 | 
             
            # Built on two universally available structures:
         | 
| 9 9 | 
             
            #   1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array.
         | 
| 10 | 
            -
            #   2. An  | 
| 10 | 
            +
            #   2. An ordered list of values. More commonly called an _array_, vector, sequence or list.
         | 
| 11 11 | 
             
            #
         | 
| 12 12 | 
             
            # To read more about JSON visit: http://json.org
         | 
| 13 13 | 
             
            #
         | 
| 14 14 | 
             
            # == Parsing JSON
         | 
| 15 15 | 
             
            #
         | 
| 16 | 
            -
            # To parse a JSON string received by another application | 
| 16 | 
            +
            # To parse a JSON string received by another application or generated within
         | 
| 17 17 | 
             
            # your existing application:
         | 
| 18 | 
            -
            # | 
| 18 | 
            +
            #
         | 
| 19 19 | 
             
            #   require 'json'
         | 
| 20 20 | 
             
            #
         | 
| 21 21 | 
             
            #   my_hash = JSON.parse('{"hello": "goodbye"}')
         | 
| @@ -32,7 +32,7 @@ | |
| 32 32 | 
             
            # just as simple.
         | 
| 33 33 | 
             
            #
         | 
| 34 34 | 
             
            #   require 'json'
         | 
| 35 | 
            -
            # | 
| 35 | 
            +
            #
         | 
| 36 36 | 
             
            #   my_hash = {:hello => "goodbye"}
         | 
| 37 37 | 
             
            #   puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}"
         | 
| 38 38 | 
             
            #
         | 
| @@ -41,9 +41,9 @@ | |
| 41 41 | 
             
            #   require 'json'
         | 
| 42 42 | 
             
            #   puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}"
         | 
| 43 43 | 
             
            #
         | 
| 44 | 
            -
            # <tt>JSON.generate</tt> only allows objects or arrays to be converted | 
| 45 | 
            -
            # to JSON syntax.  | 
| 46 | 
            -
            # even though it only  | 
| 44 | 
            +
            # <tt>JSON.generate</tt> only allows objects or arrays to be converted
         | 
| 45 | 
            +
            # to JSON syntax. <tt>to_json</tt>, however, accepts many Ruby classes
         | 
| 46 | 
            +
            # even though it acts only as a method for serialization:
         | 
| 47 47 | 
             
            #
         | 
| 48 48 | 
             
            #   require 'json'
         | 
| 49 49 | 
             
            #
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
         | 
| 2 | 
            +
              require 'json'
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
            defined?(::Complex) or require 'complex'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Complex
         | 
| 7 | 
            +
              def self.json_create(object)
         | 
| 8 | 
            +
                Complex(object['r'], object['i'])
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def as_json(*)
         | 
| 12 | 
            +
                {
         | 
| 13 | 
            +
                  JSON.create_id => self.class.name,
         | 
| 14 | 
            +
                  'r'            => real,
         | 
| 15 | 
            +
                  'i'            => imag,
         | 
| 16 | 
            +
                }
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def to_json(*)
         | 
| 20 | 
            +
                as_json.to_json
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
    
        data/lib/json/add/core.rb
    CHANGED
    
    | @@ -21,7 +21,7 @@ class Symbol | |
| 21 21 | 
             
              def to_json(*a)
         | 
| 22 22 | 
             
                as_json.to_json(*a)
         | 
| 23 23 | 
             
              end
         | 
| 24 | 
            -
             | 
| 24 | 
            +
             | 
| 25 25 | 
             
              # Deserializes JSON string by converting the <tt>string</tt> value stored in the object to a Symbol
         | 
| 26 26 | 
             
              def self.json_create(o)
         | 
| 27 27 | 
             
                o['s'].to_sym
         | 
| @@ -52,7 +52,7 @@ class Time | |
| 52 52 | 
             
                  'n'            => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
         | 
| 53 53 | 
             
                }
         | 
| 54 54 | 
             
              end
         | 
| 55 | 
            -
             | 
| 55 | 
            +
             | 
| 56 56 | 
             
              # Stores class name (Time) with number of seconds since epoch and number of
         | 
| 57 57 | 
             
              # microseconds for Time as JSON string
         | 
| 58 58 | 
             
              def to_json(*args)
         | 
| @@ -62,7 +62,7 @@ end | |
| 62 62 |  | 
| 63 63 | 
             
            # Date serialization/deserialization
         | 
| 64 64 | 
             
            class Date
         | 
| 65 | 
            -
             | 
| 65 | 
            +
             | 
| 66 66 | 
             
              # Deserializes JSON string by converting Julian year <tt>y</tt>, month
         | 
| 67 67 | 
             
              # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
         | 
| 68 68 | 
             
              def self.json_create(object)
         | 
| @@ -80,7 +80,7 @@ class Date | |
| 80 80 | 
             
                  'm' => month,
         | 
| 81 81 | 
             
                  'd' => day,
         | 
| 82 82 | 
             
                  'sg' => start,
         | 
| 83 | 
            -
                } | 
| 83 | 
            +
                }
         | 
| 84 84 | 
             
              end
         | 
| 85 85 |  | 
| 86 86 | 
             
              # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
         | 
| @@ -123,7 +123,7 @@ class DateTime | |
| 123 123 | 
             
                  'S' => sec,
         | 
| 124 124 | 
             
                  'of' => offset.to_s,
         | 
| 125 125 | 
             
                  'sg' => start,
         | 
| 126 | 
            -
                } | 
| 126 | 
            +
                }
         | 
| 127 127 | 
             
              end
         | 
| 128 128 |  | 
| 129 129 | 
             
              # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
         | 
| @@ -136,7 +136,7 @@ end | |
| 136 136 |  | 
| 137 137 | 
             
            # Range serialization/deserialization
         | 
| 138 138 | 
             
            class Range
         | 
| 139 | 
            -
             | 
| 139 | 
            +
             | 
| 140 140 | 
             
              # Deserializes JSON string by constructing new Range object with arguments
         | 
| 141 141 | 
             
              # <tt>a</tt> serialized by <tt>to_json</tt>.
         | 
| 142 142 | 
             
              def self.json_create(object)
         | 
| @@ -162,7 +162,7 @@ end | |
| 162 162 |  | 
| 163 163 | 
             
            # Struct serialization/deserialization
         | 
| 164 164 | 
             
            class Struct
         | 
| 165 | 
            -
             | 
| 165 | 
            +
             | 
| 166 166 | 
             
              # Deserializes JSON string by constructing new Struct object with values
         | 
| 167 167 | 
             
              # <tt>v</tt> serialized by <tt>to_json</tt>.
         | 
| 168 168 | 
             
              def self.json_create(object)
         | 
| @@ -230,8 +230,8 @@ class Regexp | |
| 230 230 | 
             
              def as_json(*)
         | 
| 231 231 | 
             
                {
         | 
| 232 232 | 
             
                  JSON.create_id => self.class.name,
         | 
| 233 | 
            -
                  'o' | 
| 234 | 
            -
                  's' | 
| 233 | 
            +
                  'o'            => options,
         | 
| 234 | 
            +
                  's'            => source,
         | 
| 235 235 | 
             
                }
         | 
| 236 236 | 
             
              end
         | 
| 237 237 |  | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
         | 
| 2 | 
            +
              require 'json'
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
            defined?(::Rational) or require 'rational'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Rational
         | 
| 7 | 
            +
              def self.json_create(object)
         | 
| 8 | 
            +
                Rational(object['n'], object['d'])
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def as_json(*)
         | 
| 12 | 
            +
                {
         | 
| 13 | 
            +
                  JSON.create_id => self.class.name,
         | 
| 14 | 
            +
                  'n'            => numerator,
         | 
| 15 | 
            +
                  'd'            => denominator,
         | 
| 16 | 
            +
                }
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def to_json(*)
         | 
| 20 | 
            +
                as_json.to_json
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
    
        data/lib/json/common.rb
    CHANGED
    
    | @@ -2,11 +2,11 @@ require 'json/version' | |
| 2 2 |  | 
| 3 3 | 
             
            module JSON
         | 
| 4 4 | 
             
              class << self
         | 
| 5 | 
            -
                # If _object_ is string-like parse the string and return the parsed result
         | 
| 5 | 
            +
                # If _object_ is string-like, parse the string and return the parsed result
         | 
| 6 6 | 
             
                # as a Ruby data structure. Otherwise generate a JSON text from the Ruby
         | 
| 7 7 | 
             
                # data structure object and return it.
         | 
| 8 8 | 
             
                #
         | 
| 9 | 
            -
                # The _opts_ argument is passed through to generate/parse respectively | 
| 9 | 
            +
                # The _opts_ argument is passed through to generate/parse respectively. See
         | 
| 10 10 | 
             
                # generate and parse for their documentation.
         | 
| 11 11 | 
             
                def [](object, opts = {})
         | 
| 12 12 | 
             
                  if object.respond_to? :to_str
         | 
| @@ -16,7 +16,7 @@ module JSON | |
| 16 16 | 
             
                  end
         | 
| 17 17 | 
             
                end
         | 
| 18 18 |  | 
| 19 | 
            -
                # Returns the JSON parser class | 
| 19 | 
            +
                # Returns the JSON parser class that is used by JSON. This is either
         | 
| 20 20 | 
             
                # JSON::Ext::Parser or JSON::Pure::Parser.
         | 
| 21 21 | 
             
                attr_reader :parser
         | 
| 22 22 |  | 
| @@ -28,7 +28,7 @@ module JSON | |
| 28 28 | 
             
                end
         | 
| 29 29 |  | 
| 30 30 | 
             
                # Return the constant located at _path_. The format of _path_ has to be
         | 
| 31 | 
            -
                # either ::A::B::C or A::B::C. In any case A has to be located at the top
         | 
| 31 | 
            +
                # either ::A::B::C or A::B::C. In any case, A has to be located at the top
         | 
| 32 32 | 
             
                # level (absolute namespace path?). If there doesn't exist a constant at
         | 
| 33 33 | 
             
                # the given path, an ArgumentError is raised.
         | 
| 34 34 | 
             
                def deep_const_get(path) # :nodoc:
         | 
| @@ -81,15 +81,15 @@ module JSON | |
| 81 81 | 
             
                  $VERBOSE = old
         | 
| 82 82 | 
             
                end
         | 
| 83 83 |  | 
| 84 | 
            -
                # Returns the JSON generator  | 
| 84 | 
            +
                # Returns the JSON generator module that is used by JSON. This is
         | 
| 85 85 | 
             
                # either JSON::Ext::Generator or JSON::Pure::Generator.
         | 
| 86 86 | 
             
                attr_reader :generator
         | 
| 87 87 |  | 
| 88 | 
            -
                # Returns the JSON generator state class | 
| 89 | 
            -
                #  | 
| 88 | 
            +
                # Returns the JSON generator state class that is used by JSON. This is
         | 
| 89 | 
            +
                # either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
         | 
| 90 90 | 
             
                attr_accessor :state
         | 
| 91 91 |  | 
| 92 | 
            -
                # This is create identifier,  | 
| 92 | 
            +
                # This is create identifier, which is used to decide if the _json_create_
         | 
| 93 93 | 
             
                # hook of a class should be called. It defaults to 'json_class'.
         | 
| 94 94 | 
             
                attr_accessor :create_id
         | 
| 95 95 | 
             
              end
         | 
| @@ -104,10 +104,10 @@ module JSON | |
| 104 104 | 
             
              # The base exception for JSON errors.
         | 
| 105 105 | 
             
              class JSONError < StandardError; end
         | 
| 106 106 |  | 
| 107 | 
            -
              # This exception is raised | 
| 107 | 
            +
              # This exception is raised if a parser error occurs.
         | 
| 108 108 | 
             
              class ParserError < JSONError; end
         | 
| 109 109 |  | 
| 110 | 
            -
              # This exception is raised | 
| 110 | 
            +
              # This exception is raised if the nesting of parsed data structures is too
         | 
| 111 111 | 
             
              # deep.
         | 
| 112 112 | 
             
              class NestingError < ParserError; end
         | 
| 113 113 |  | 
| @@ -115,13 +115,13 @@ module JSON | |
| 115 115 | 
             
              class CircularDatastructure < NestingError; end
         | 
| 116 116 | 
             
              # :startdoc:
         | 
| 117 117 |  | 
| 118 | 
            -
              # This exception is raised | 
| 118 | 
            +
              # This exception is raised if a generator or unparser error occurs.
         | 
| 119 119 | 
             
              class GeneratorError < JSONError; end
         | 
| 120 120 | 
             
              # For backwards compatibility
         | 
| 121 121 | 
             
              UnparserError = GeneratorError
         | 
| 122 122 |  | 
| 123 | 
            -
              # This exception is raised | 
| 124 | 
            -
              # system. Usually this means | 
| 123 | 
            +
              # This exception is raised if the required unicode support is missing on the
         | 
| 124 | 
            +
              # system. Usually this means that the iconv library is not installed.
         | 
| 125 125 | 
             
              class MissingUnicodeSupport < JSONError; end
         | 
| 126 126 |  | 
| 127 127 | 
             
              module_function
         | 
| @@ -131,16 +131,16 @@ module JSON | |
| 131 131 | 
             
              # _opts_ can have the following
         | 
| 132 132 | 
             
              # keys:
         | 
| 133 133 | 
             
              # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
         | 
| 134 | 
            -
              #   structures. Disable depth checking with :max_nesting => false | 
| 134 | 
            +
              #   structures. Disable depth checking with :max_nesting => false. It defaults
         | 
| 135 135 | 
             
              #   to 19.
         | 
| 136 136 | 
             
              # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
         | 
| 137 137 | 
             
              #   defiance of RFC 4627 to be parsed by the Parser. This option defaults
         | 
| 138 138 | 
             
              #   to false.
         | 
| 139 139 | 
             
              # * *symbolize_names*: If set to true, returns symbols for the names
         | 
| 140 | 
            -
              #   (keys) in a JSON object. Otherwise strings are returned | 
| 140 | 
            +
              #   (keys) in a JSON object. Otherwise strings are returned. Strings are
         | 
| 141 141 | 
             
              #   the default.
         | 
| 142 142 | 
             
              # * *create_additions*: If set to false, the Parser doesn't create
         | 
| 143 | 
            -
              #   additions even if a  | 
| 143 | 
            +
              #   additions even if a matching class and create_id was found. This option
         | 
| 144 144 | 
             
              #   defaults to true.
         | 
| 145 145 | 
             
              # * *object_class*: Defaults to Hash
         | 
| 146 146 | 
             
              # * *array_class*: Defaults to Array
         | 
| @@ -149,19 +149,19 @@ module JSON | |
| 149 149 | 
             
              end
         | 
| 150 150 |  | 
| 151 151 | 
             
              # Parse the JSON document _source_ into a Ruby data structure and return it.
         | 
| 152 | 
            -
              # The bang version of the parse method | 
| 152 | 
            +
              # The bang version of the parse method defaults to the more dangerous values
         | 
| 153 153 | 
             
              # for the _opts_ hash, so be sure only to parse trusted _source_ documents.
         | 
| 154 154 | 
             
              #
         | 
| 155 155 | 
             
              # _opts_ can have the following keys:
         | 
| 156 156 | 
             
              # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
         | 
| 157 157 | 
             
              #   structures. Enable depth checking with :max_nesting => anInteger. The parse!
         | 
| 158 | 
            -
              #   methods defaults to not doing max depth checking: This can be dangerous | 
| 158 | 
            +
              #   methods defaults to not doing max depth checking: This can be dangerous
         | 
| 159 159 | 
             
              #   if someone wants to fill up your stack.
         | 
| 160 160 | 
             
              # * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
         | 
| 161 161 | 
             
              #   defiance of RFC 4627 to be parsed by the Parser. This option defaults
         | 
| 162 162 | 
             
              #   to true.
         | 
| 163 163 | 
             
              # * *create_additions*: If set to false, the Parser doesn't create
         | 
| 164 | 
            -
              #   additions even if a  | 
| 164 | 
            +
              #   additions even if a matching class and create_id was found. This option
         | 
| 165 165 | 
             
              #   defaults to true.
         | 
| 166 166 | 
             
              def parse!(source, opts = {})
         | 
| 167 167 | 
             
                opts = {
         | 
| @@ -185,10 +185,10 @@ module JSON | |
| 185 185 | 
             
              # * *indent*: a string used to indent levels (default: ''),
         | 
| 186 186 | 
             
              # * *space*: a string that is put after, a : or , delimiter (default: ''),
         | 
| 187 187 | 
             
              # * *space_before*: a string that is put before a : pair delimiter (default: ''),
         | 
| 188 | 
            -
              # * *object_nl*: a string that is put at the end of a JSON object (default: ''), | 
| 188 | 
            +
              # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
         | 
| 189 189 | 
             
              # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
         | 
| 190 190 | 
             
              # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
         | 
| 191 | 
            -
              #   generated, otherwise an exception is thrown | 
| 191 | 
            +
              #   generated, otherwise an exception is thrown if these values are
         | 
| 192 192 | 
             
              #   encountered. This options defaults to false.
         | 
| 193 193 | 
             
              # * *max_nesting*: The maximum depth of nesting allowed in the data
         | 
| 194 194 | 
             
              #   structures from which JSON is to be generated. Disable depth checking
         | 
| @@ -196,9 +196,13 @@ module JSON | |
| 196 196 | 
             
              #
         | 
| 197 197 | 
             
              # See also the fast_generate for the fastest creation method with the least
         | 
| 198 198 | 
             
              # amount of sanity checks, and the pretty_generate method for some
         | 
| 199 | 
            -
              # defaults for  | 
| 199 | 
            +
              # defaults for pretty output.
         | 
| 200 200 | 
             
              def generate(obj, opts = nil)
         | 
| 201 | 
            -
                 | 
| 201 | 
            +
                if State === opts
         | 
| 202 | 
            +
                  state, opts = opts, nil
         | 
| 203 | 
            +
                else
         | 
| 204 | 
            +
                  state = SAFE_STATE_PROTOTYPE.dup
         | 
| 205 | 
            +
                end
         | 
| 202 206 | 
             
                if opts
         | 
| 203 207 | 
             
                  if opts.respond_to? :to_hash
         | 
| 204 208 | 
             
                    opts = opts.to_hash
         | 
| @@ -223,9 +227,13 @@ module JSON | |
| 223 227 | 
             
              # This method disables the checks for circles in Ruby objects.
         | 
| 224 228 | 
             
              #
         | 
| 225 229 | 
             
              # *WARNING*: Be careful not to pass any Ruby data structures with circles as
         | 
| 226 | 
            -
              # _obj_ argument | 
| 230 | 
            +
              # _obj_ argument because this will cause JSON to go into an infinite loop.
         | 
| 227 231 | 
             
              def fast_generate(obj, opts = nil)
         | 
| 228 | 
            -
                 | 
| 232 | 
            +
                if State === opts
         | 
| 233 | 
            +
                  state, opts = opts, nil
         | 
| 234 | 
            +
                else
         | 
| 235 | 
            +
                  state = FAST_STATE_PROTOTYPE.dup
         | 
| 236 | 
            +
                end
         | 
| 229 237 | 
             
                if opts
         | 
| 230 238 | 
             
                  if opts.respond_to? :to_hash
         | 
| 231 239 | 
             
                    opts = opts.to_hash
         | 
| @@ -249,10 +257,14 @@ module JSON | |
| 249 257 | 
             
              # The returned document is a prettier form of the document returned by
         | 
| 250 258 | 
             
              # #unparse.
         | 
| 251 259 | 
             
              #
         | 
| 252 | 
            -
              # The _opts_ argument can be used to configure the generator | 
| 260 | 
            +
              # The _opts_ argument can be used to configure the generator. See the
         | 
| 253 261 | 
             
              # generate method for a more detailed explanation.
         | 
| 254 262 | 
             
              def pretty_generate(obj, opts = nil)
         | 
| 255 | 
            -
                 | 
| 263 | 
            +
                if State === opts
         | 
| 264 | 
            +
                  state, opts = opts, nil
         | 
| 265 | 
            +
                else
         | 
| 266 | 
            +
                  state = PRETTY_STATE_PROTOTYPE.dup
         | 
| 267 | 
            +
                end
         | 
| 256 268 | 
             
                if opts
         | 
| 257 269 | 
             
                  if opts.respond_to? :to_hash
         | 
| 258 270 | 
             
                    opts = opts.to_hash
         | 
| @@ -273,7 +285,7 @@ module JSON | |
| 273 285 | 
             
              # :startdoc:
         | 
| 274 286 |  | 
| 275 287 | 
             
              # Load a ruby data structure from a JSON _source_ and return it. A source can
         | 
| 276 | 
            -
              # either be a string-like object, an IO | 
| 288 | 
            +
              # either be a string-like object, an IO-like object, or an object responding
         | 
| 277 289 | 
             
              # to the read method. If _proc_ was given, it will be called with any nested
         | 
| 278 290 | 
             
              # Ruby object as an argument recursively in depth first order.
         | 
| 279 291 | 
             
              #
         | 
| @@ -291,7 +303,7 @@ module JSON | |
| 291 303 | 
             
                recurse_proc(result, &proc) if proc
         | 
| 292 304 | 
             
                result
         | 
| 293 305 | 
             
              end
         | 
| 294 | 
            -
             | 
| 306 | 
            +
             | 
| 295 307 | 
             
              # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
         | 
| 296 308 | 
             
              def recurse_proc(result, &proc)
         | 
| 297 309 | 
             
                case result
         | 
| @@ -312,10 +324,10 @@ module JSON | |
| 312 324 | 
             
              # Dumps _obj_ as a JSON string, i.e. calls generate on the object and returns
         | 
| 313 325 | 
             
              # the result.
         | 
| 314 326 | 
             
              #
         | 
| 315 | 
            -
              # If anIO (an IO | 
| 327 | 
            +
              # If anIO (an IO-like object or an object that responds to the write method)
         | 
| 316 328 | 
             
              # was given, the resulting JSON is written to it.
         | 
| 317 329 | 
             
              #
         | 
| 318 | 
            -
              # If the number of nested arrays or objects exceeds _limit_ an ArgumentError
         | 
| 330 | 
            +
              # If the number of nested arrays or objects exceeds _limit_, an ArgumentError
         | 
| 319 331 | 
             
              # exception is raised. This argument is similar (but not exactly the
         | 
| 320 332 | 
             
              # same!) to the _limit_ argument in Marshal.dump.
         | 
| 321 333 | 
             
              #
         | 
| @@ -360,7 +372,7 @@ module JSON | |
| 360 372 | 
             
                require 'iconv'
         | 
| 361 373 | 
             
                # Encodes string using _iconv_ library
         | 
| 362 374 | 
             
                def self.iconv(to, from, string)
         | 
| 363 | 
            -
                  Iconv. | 
| 375 | 
            +
                  Iconv.conv(to, from, string)
         | 
| 364 376 | 
             
                end
         | 
| 365 377 | 
             
              end
         | 
| 366 378 |  | 
| @@ -396,11 +408,11 @@ module ::Kernel | |
| 396 408 | 
             
                nil
         | 
| 397 409 | 
             
              end
         | 
| 398 410 |  | 
| 399 | 
            -
              # If _object_ is string-like parse the string and return the parsed result as
         | 
| 400 | 
            -
              # a Ruby data structure. Otherwise generate a JSON text from the Ruby data
         | 
| 411 | 
            +
              # If _object_ is string-like, parse the string and return the parsed result as
         | 
| 412 | 
            +
              # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
         | 
| 401 413 | 
             
              # structure object and return it.
         | 
| 402 414 | 
             
              #
         | 
| 403 | 
            -
              # The _opts_ argument is passed through to generate/parse respectively | 
| 415 | 
            +
              # The _opts_ argument is passed through to generate/parse respectively. See
         | 
| 404 416 | 
             
              # generate and parse for their documentation.
         | 
| 405 417 | 
             
              def JSON(object, *args)
         | 
| 406 418 | 
             
                if object.respond_to? :to_str
         | 
| @@ -413,10 +425,10 @@ end | |
| 413 425 |  | 
| 414 426 | 
             
            # Extends any Class to include _json_creatable?_ method.
         | 
| 415 427 | 
             
            class ::Class
         | 
| 416 | 
            -
              # Returns true | 
| 428 | 
            +
              # Returns true if this class can be used to create an instance
         | 
| 417 429 | 
             
              # from a serialised JSON string. The class has to implement a class
         | 
| 418 | 
            -
              # method _json_create_ that expects a hash as first parameter | 
| 419 | 
            -
              # the required data.
         | 
| 430 | 
            +
              # method _json_create_ that expects a hash as first parameter. The hash
         | 
| 431 | 
            +
              # should include the required data.
         | 
| 420 432 | 
             
              def json_creatable?
         | 
| 421 433 | 
             
                respond_to?(:json_create)
         | 
| 422 434 | 
             
              end
         | 
    
        data/lib/json/editor.rb
    CHANGED
    
    | @@ -47,14 +47,14 @@ module JSON | |
| 47 47 | 
             
                # Opens an error dialog on top of _window_ showing the error message
         | 
| 48 48 | 
             
                # _text_.
         | 
| 49 49 | 
             
                def Editor.error_dialog(window, text)
         | 
| 50 | 
            -
                  dialog = MessageDialog.new(window, Dialog::MODAL, | 
| 51 | 
            -
                    MessageDialog::ERROR, | 
| 50 | 
            +
                  dialog = MessageDialog.new(window, Dialog::MODAL,
         | 
| 51 | 
            +
                    MessageDialog::ERROR,
         | 
| 52 52 | 
             
                    MessageDialog::BUTTONS_CLOSE, text)
         | 
| 53 53 | 
             
                  dialog.show_all
         | 
| 54 54 | 
             
                  dialog.run
         | 
| 55 55 | 
             
                rescue TypeError
         | 
| 56 | 
            -
                  dialog = MessageDialog.new(Editor.window, Dialog::MODAL, | 
| 57 | 
            -
                    MessageDialog::ERROR, | 
| 56 | 
            +
                  dialog = MessageDialog.new(Editor.window, Dialog::MODAL,
         | 
| 57 | 
            +
                    MessageDialog::ERROR,
         | 
| 58 58 | 
             
                    MessageDialog::BUTTONS_CLOSE, text)
         | 
| 59 59 | 
             
                  dialog.show_all
         | 
| 60 60 | 
             
                  dialog.run
         | 
| @@ -66,8 +66,8 @@ module JSON | |
| 66 66 | 
             
                # message _text_. If yes was answered _true_ is returned, otherwise
         | 
| 67 67 | 
             
                # _false_.
         | 
| 68 68 | 
             
                def Editor.question_dialog(window, text)
         | 
| 69 | 
            -
                  dialog = MessageDialog.new(window, Dialog::MODAL, | 
| 70 | 
            -
                    MessageDialog::QUESTION, | 
| 69 | 
            +
                  dialog = MessageDialog.new(window, Dialog::MODAL,
         | 
| 70 | 
            +
                    MessageDialog::QUESTION,
         | 
| 71 71 | 
             
                    MessageDialog::BUTTONS_YES_NO, text)
         | 
| 72 72 | 
             
                  dialog.show_all
         | 
| 73 73 | 
             
                  dialog.run do |response|
         | 
| @@ -464,7 +464,7 @@ module JSON | |
| 464 464 | 
             
                    add_separator
         | 
| 465 465 | 
             
                    add_item("Append new node", ?a, &method(:append_new_node))
         | 
| 466 466 | 
             
                    add_item("Insert new node before", ?i, &method(:insert_new_node))
         | 
| 467 | 
            -
                    add_separator | 
| 467 | 
            +
                    add_separator
         | 
| 468 468 | 
             
                    add_item("Collapse/Expand node (recursively)", ?e,
         | 
| 469 469 | 
             
                      &method(:collapse_expand))
         | 
| 470 470 |  | 
| @@ -503,7 +503,7 @@ module JSON | |
| 503 503 | 
             
                  # Revert the current JSON document in the editor to the saved version.
         | 
| 504 504 | 
             
                  def revert(item)
         | 
| 505 505 | 
             
                    window.instance_eval do
         | 
| 506 | 
            -
                      @filename and file_open(@filename) | 
| 506 | 
            +
                      @filename and file_open(@filename)
         | 
| 507 507 | 
             
                    end
         | 
| 508 508 | 
             
                  end
         | 
| 509 509 |  | 
| @@ -665,7 +665,7 @@ module JSON | |
| 665 665 | 
             
                      collapse_all
         | 
| 666 666 | 
             
                    else
         | 
| 667 667 | 
             
                      self.expanded = true
         | 
| 668 | 
            -
                      expand_all | 
| 668 | 
            +
                      expand_all
         | 
| 669 669 | 
             
                    end
         | 
| 670 670 | 
             
                  end
         | 
| 671 671 |  | 
| @@ -884,7 +884,7 @@ module JSON | |
| 884 884 | 
             
                    dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
         | 
| 885 885 | 
             
                    dialog.show_all
         | 
| 886 886 | 
             
                    self.focus = dialog
         | 
| 887 | 
            -
                    dialog.run do |response| | 
| 887 | 
            +
                    dialog.run do |response|
         | 
| 888 888 | 
             
                      if response == Dialog::RESPONSE_ACCEPT
         | 
| 889 889 | 
             
                        @key = key_input.text
         | 
| 890 890 | 
             
                        type = ALL_TYPES[@type = type_input.active]
         | 
| @@ -936,7 +936,7 @@ module JSON | |
| 936 936 | 
             
                    dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
         | 
| 937 937 | 
             
                    dialog.show_all
         | 
| 938 938 | 
             
                    self.focus = dialog
         | 
| 939 | 
            -
                    dialog.run do |response| | 
| 939 | 
            +
                    dialog.run do |response|
         | 
| 940 940 | 
             
                      if response == Dialog::RESPONSE_ACCEPT
         | 
| 941 941 | 
             
                        type = types[type_input.active]
         | 
| 942 942 | 
             
                        @content = case type
         | 
| @@ -981,7 +981,7 @@ module JSON | |
| 981 981 | 
             
                    dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
         | 
| 982 982 | 
             
                    dialog.show_all
         | 
| 983 983 | 
             
                    self.focus = dialog
         | 
| 984 | 
            -
                    dialog.run do |response| | 
| 984 | 
            +
                    dialog.run do |response|
         | 
| 985 985 | 
             
                      if response == Dialog::RESPONSE_ACCEPT
         | 
| 986 986 | 
             
                        return @order = order_input.text, reverse_checkbox.active?
         | 
| 987 987 | 
             
                      end
         | 
| @@ -1016,7 +1016,7 @@ module JSON | |
| 1016 1016 | 
             
                    dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
         | 
| 1017 1017 | 
             
                    dialog.show_all
         | 
| 1018 1018 | 
             
                    self.focus = dialog
         | 
| 1019 | 
            -
                    dialog.run do |response| | 
| 1019 | 
            +
                    dialog.run do |response|
         | 
| 1020 1020 | 
             
                      if response == Dialog::RESPONSE_ACCEPT
         | 
| 1021 1021 | 
             
                        begin
         | 
| 1022 1022 | 
             
                          return Regexp.new(regex_input.text, icase_checkbox.active? ? Regexp::IGNORECASE : 0)
         | 
| @@ -1215,7 +1215,7 @@ module JSON | |
| 1215 1215 | 
             
                    end
         | 
| 1216 1216 | 
             
                  end
         | 
| 1217 1217 |  | 
| 1218 | 
            -
                  # Save the current file as the filename | 
| 1218 | 
            +
                  # Save the current file as the filename
         | 
| 1219 1219 | 
             
                  def file_save_as
         | 
| 1220 1220 | 
             
                    filename = select_file('Save as a JSON file')
         | 
| 1221 1221 | 
             
                    store_file(filename)
         | 
| @@ -1241,7 +1241,7 @@ module JSON | |
| 1241 1241 | 
             
                  rescue SystemCallError => e
         | 
| 1242 1242 | 
             
                    Editor.error_dialog(self, "Failed to store JSON file: #{e}!")
         | 
| 1243 1243 | 
             
                  end
         | 
| 1244 | 
            -
             | 
| 1244 | 
            +
             | 
| 1245 1245 | 
             
                  # Load the file named _filename_ into the editor as a JSON document.
         | 
| 1246 1246 | 
             
                  def load_file(filename)
         | 
| 1247 1247 | 
             
                    if filename
         | 
| @@ -1333,7 +1333,7 @@ module JSON | |
| 1333 1333 |  | 
| 1334 1334 | 
             
                    dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
         | 
| 1335 1335 | 
             
                    dialog.show_all
         | 
| 1336 | 
            -
                    dialog.run do |response| | 
| 1336 | 
            +
                    dialog.run do |response|
         | 
| 1337 1337 | 
             
                      if response == Dialog::RESPONSE_ACCEPT
         | 
| 1338 1338 | 
             
                        return @location = location_input.text
         | 
| 1339 1339 | 
             
                      end
         | 
    
        data/lib/json/ext.rb
    CHANGED
    
    | @@ -4,21 +4,8 @@ module JSON | |
| 4 4 | 
             
              # This module holds all the modules/classes that implement JSON's
         | 
| 5 5 | 
             
              # functionality as C extensions.
         | 
| 6 6 | 
             
              module Ext
         | 
| 7 | 
            -
                 | 
| 8 | 
            -
             | 
| 9 | 
            -
                    require 'json/ext/1.9/parser'
         | 
| 10 | 
            -
                    require 'json/ext/1.9/generator'
         | 
| 11 | 
            -
                  elsif !defined?(RUBY_ENGINE) && RUBY_VERSION =~ /\A1\.8\./
         | 
| 12 | 
            -
                    require 'json/ext/1.8/parser'
         | 
| 13 | 
            -
                    require 'json/ext/1.8/generator'
         | 
| 14 | 
            -
                  else
         | 
| 15 | 
            -
                    require 'json/ext/parser'
         | 
| 16 | 
            -
                    require 'json/ext/generator'
         | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
                rescue LoadError
         | 
| 19 | 
            -
                  require 'json/ext/parser'
         | 
| 20 | 
            -
                  require 'json/ext/generator'
         | 
| 21 | 
            -
                end
         | 
| 7 | 
            +
                require 'json/ext/parser'
         | 
| 8 | 
            +
                require 'json/ext/generator'
         | 
| 22 9 | 
             
                $DEBUG and warn "Using Ext extension for JSON."
         | 
| 23 10 | 
             
                JSON.parser = Parser
         | 
| 24 11 | 
             
                JSON.generator = Generator
         | 
    
        data/lib/json/ext/generator.jar
    CHANGED
    
    | Binary file | 
    
        data/lib/json/ext/parser.jar
    CHANGED
    
    | Binary file | 
    
        data/lib/json/pure/generator.rb
    CHANGED
    
    | @@ -125,7 +125,7 @@ module JSON | |
| 125 125 | 
             
                    # * *indent*: a string used to indent levels (default: ''),
         | 
| 126 126 | 
             
                    # * *space*: a string that is put after, a : or , delimiter (default: ''),
         | 
| 127 127 | 
             
                    # * *space_before*: a string that is put before a : pair delimiter (default: ''),
         | 
| 128 | 
            -
                    # * *object_nl*: a string that is put at the end of a JSON object (default: ''), | 
| 128 | 
            +
                    # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
         | 
| 129 129 | 
             
                    # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
         | 
| 130 130 | 
             
                    # * *check_circular*: is deprecated now, use the :max_nesting option instead,
         | 
| 131 131 | 
             
                    # * *max_nesting*: sets the maximum level of data structure nesting in
         | 
| @@ -133,6 +133,8 @@ module JSON | |
| 133 133 | 
             
                    # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
         | 
| 134 134 | 
             
                    #   generated, otherwise an exception is thrown, if these values are
         | 
| 135 135 | 
             
                    #   encountered. This options defaults to false.
         | 
| 136 | 
            +
                    # * *quirks_mode*: Enables quirks_mode for parser, that is for example
         | 
| 137 | 
            +
                    #   generating single JSON values instead of documents is possible.
         | 
| 136 138 | 
             
                    def initialize(opts = {})
         | 
| 137 139 | 
             
                      @indent         = ''
         | 
| 138 140 | 
             
                      @space          = ''
         | 
| @@ -141,6 +143,7 @@ module JSON | |
| 141 143 | 
             
                      @array_nl       = ''
         | 
| 142 144 | 
             
                      @allow_nan      = false
         | 
| 143 145 | 
             
                      @ascii_only     = false
         | 
| 146 | 
            +
                      @quirks_mode    = false
         | 
| 144 147 | 
             
                      configure opts
         | 
| 145 148 | 
             
                    end
         | 
| 146 149 |  | 
| @@ -165,6 +168,10 @@ module JSON | |
| 165 168 | 
             
                    # the generated JSON, max_nesting = 0 if no maximum is checked.
         | 
| 166 169 | 
             
                    attr_accessor :max_nesting
         | 
| 167 170 |  | 
| 171 | 
            +
                    # If this attribute is set to true, quirks mode is enabled, otherwise
         | 
| 172 | 
            +
                    # it's disabled.
         | 
| 173 | 
            +
                    attr_accessor :quirks_mode
         | 
| 174 | 
            +
             | 
| 168 175 | 
             
                    # This integer returns the current depth data structure nesting in the
         | 
| 169 176 | 
             
                    # generated JSON.
         | 
| 170 177 | 
             
                    attr_accessor :depth
         | 
| @@ -188,10 +195,17 @@ module JSON | |
| 188 195 | 
             
                      @allow_nan
         | 
| 189 196 | 
             
                    end
         | 
| 190 197 |  | 
| 198 | 
            +
                    # Returns true, if only ASCII characters should be generated. Otherwise
         | 
| 199 | 
            +
                    # returns false.
         | 
| 191 200 | 
             
                    def ascii_only?
         | 
| 192 201 | 
             
                      @ascii_only
         | 
| 193 202 | 
             
                    end
         | 
| 194 203 |  | 
| 204 | 
            +
                    # Returns true, if quirks mode is enabled. Otherwise returns false.
         | 
| 205 | 
            +
                    def quirks_mode?
         | 
| 206 | 
            +
                      @quirks_mode
         | 
| 207 | 
            +
                    end
         | 
| 208 | 
            +
             | 
| 195 209 | 
             
                    # Configure this State instance with the Hash _opts_, and return
         | 
| 196 210 | 
             
                    # itself.
         | 
| 197 211 | 
             
                    def configure(opts)
         | 
| @@ -203,6 +217,7 @@ module JSON | |
| 203 217 | 
             
                      @allow_nan      = !!opts[:allow_nan] if opts.key?(:allow_nan)
         | 
| 204 218 | 
             
                      @ascii_only     = opts[:ascii_only] if opts.key?(:ascii_only)
         | 
| 205 219 | 
             
                      @depth          = opts[:depth] || 0
         | 
| 220 | 
            +
                      @quirks_mode    = opts[:quirks_mode] if opts.key?(:quirks_mode)
         | 
| 206 221 | 
             
                      if !opts.key?(:max_nesting) # defaults to 19
         | 
| 207 222 | 
             
                        @max_nesting = 19
         | 
| 208 223 | 
             
                      elsif opts[:max_nesting]
         | 
| @@ -218,7 +233,7 @@ module JSON | |
| 218 233 | 
             
                    # passed to the configure method.
         | 
| 219 234 | 
             
                    def to_h
         | 
| 220 235 | 
             
                      result = {}
         | 
| 221 | 
            -
                      for iv in %w[indent space space_before object_nl array_nl allow_nan max_nesting ascii_only depth]
         | 
| 236 | 
            +
                      for iv in %w[indent space space_before object_nl array_nl allow_nan max_nesting ascii_only quirks_mode depth]
         | 
| 222 237 | 
             
                        result[iv.intern] = instance_variable_get("@#{iv}")
         | 
| 223 238 | 
             
                      end
         | 
| 224 239 | 
             
                      result
         | 
| @@ -229,7 +244,7 @@ module JSON | |
| 229 244 | 
             
                    # GeneratorError exception.
         | 
| 230 245 | 
             
                    def generate(obj)
         | 
| 231 246 | 
             
                      result = obj.to_json(self)
         | 
| 232 | 
            -
                      if result !~ /\A\s*(?:\[.*\]|\{.*\})\s*\Z/m
         | 
| 247 | 
            +
                      if !@quirks_mode && result !~ /\A\s*(?:\[.*\]|\{.*\})\s*\Z/m
         | 
| 233 248 | 
             
                        raise GeneratorError, "only generation of JSON objects or arrays allowed"
         | 
| 234 249 | 
             
                      end
         | 
| 235 250 | 
             
                      result
         | 
    
        data/lib/json/pure/parser.rb
    CHANGED
    
    | @@ -41,7 +41,7 @@ module JSON | |
| 41 41 | 
             
                      [^*/]|        # normal chars
         | 
| 42 42 | 
             
                      /[^*]|        # slashes that do not start a nested comment
         | 
| 43 43 | 
             
                      \*[^/]|       # asterisks that do not end this comment
         | 
| 44 | 
            -
                      /(?=\*/)      # single slash before this comment's end | 
| 44 | 
            +
                      /(?=\*/)      # single slash before this comment's end
         | 
| 45 45 | 
             
                     )*
         | 
| 46 46 | 
             
                       \*/               # the End of this comment
         | 
| 47 47 | 
             
                       |[ \t\r\n]+       # whitespaces: space, horicontal tab, lf, cr
         | 
| @@ -68,42 +68,12 @@ module JSON | |
| 68 68 | 
             
                  #   defaults to true.
         | 
| 69 69 | 
             
                  # * *object_class*: Defaults to Hash
         | 
| 70 70 | 
             
                  # * *array_class*: Defaults to Array
         | 
| 71 | 
            +
                  # * *quirks_mode*: Enables quirks_mode for parser, that is for example
         | 
| 72 | 
            +
                  #   parsing single JSON values instead of documents is possible.
         | 
| 71 73 | 
             
                  def initialize(source, opts = {})
         | 
| 72 74 | 
             
                    opts ||= {}
         | 
| 73 | 
            -
                     | 
| 74 | 
            -
                       | 
| 75 | 
            -
                        b = source[0, 4].bytes.to_a
         | 
| 76 | 
            -
                        source = case
         | 
| 77 | 
            -
                                 when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
         | 
| 78 | 
            -
                                   source.dup.force_encoding(::Encoding::UTF_32BE).encode!(::Encoding::UTF_8)
         | 
| 79 | 
            -
                                 when b.size >= 4 && b[0] == 0 && b[2] == 0
         | 
| 80 | 
            -
                                   source.dup.force_encoding(::Encoding::UTF_16BE).encode!(::Encoding::UTF_8)
         | 
| 81 | 
            -
                                 when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
         | 
| 82 | 
            -
                                   source.dup.force_encoding(::Encoding::UTF_32LE).encode!(::Encoding::UTF_8)
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                                 when b.size >= 4 && b[1] == 0 && b[3] == 0
         | 
| 85 | 
            -
                                   source.dup.force_encoding(::Encoding::UTF_16LE).encode!(::Encoding::UTF_8)
         | 
| 86 | 
            -
                                 else
         | 
| 87 | 
            -
                                   source.dup
         | 
| 88 | 
            -
                                 end
         | 
| 89 | 
            -
                      else
         | 
| 90 | 
            -
                        source = source.encode(::Encoding::UTF_8)
         | 
| 91 | 
            -
                      end
         | 
| 92 | 
            -
                      source.force_encoding(::Encoding::ASCII_8BIT)
         | 
| 93 | 
            -
                    else
         | 
| 94 | 
            -
                      b = source
         | 
| 95 | 
            -
                      source = case
         | 
| 96 | 
            -
                               when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
         | 
| 97 | 
            -
                                 JSON.iconv('utf-8', 'utf-32be', b)
         | 
| 98 | 
            -
                               when b.size >= 4 && b[0] == 0 && b[2] == 0
         | 
| 99 | 
            -
                                 JSON.iconv('utf-8', 'utf-16be', b)
         | 
| 100 | 
            -
                               when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
         | 
| 101 | 
            -
                                 JSON.iconv('utf-8', 'utf-32le', b)
         | 
| 102 | 
            -
                               when b.size >= 4 && b[1] == 0 && b[3] == 0
         | 
| 103 | 
            -
                                 JSON.iconv('utf-8', 'utf-16le', b)
         | 
| 104 | 
            -
                               else
         | 
| 105 | 
            -
                                 b
         | 
| 106 | 
            -
                               end
         | 
| 75 | 
            +
                    unless @quirks_mode = opts[:quirks_mode]
         | 
| 76 | 
            +
                      source = determine_encoding source
         | 
| 107 77 | 
             
                    end
         | 
| 108 78 | 
             
                    super source
         | 
| 109 79 | 
             
                    if !opts.key?(:max_nesting) # defaults to 19
         | 
| @@ -113,44 +83,108 @@ module JSON | |
| 113 83 | 
             
                    else
         | 
| 114 84 | 
             
                      @max_nesting = 0
         | 
| 115 85 | 
             
                    end
         | 
| 116 | 
            -
                    @allow_nan | 
| 117 | 
            -
                    @symbolize_names | 
| 118 | 
            -
                     | 
| 119 | 
            -
             | 
| 120 | 
            -
                     | 
| 121 | 
            -
             | 
| 122 | 
            -
                     | 
| 86 | 
            +
                    @allow_nan = !!opts[:allow_nan]
         | 
| 87 | 
            +
                    @symbolize_names = !!opts[:symbolize_names]
         | 
| 88 | 
            +
                    if opts.key?(:create_additions)
         | 
| 89 | 
            +
                      @create_additions = !!opts[:create_additions]
         | 
| 90 | 
            +
                    else
         | 
| 91 | 
            +
                      @create_additions = true
         | 
| 92 | 
            +
                    end
         | 
| 93 | 
            +
                    @create_id = @create_additions ? JSON.create_id : nil
         | 
| 94 | 
            +
                    @object_class = opts[:object_class] || Hash
         | 
| 95 | 
            +
                    @array_class  = opts[:array_class] || Array
         | 
| 96 | 
            +
                    @match_string = opts[:match_string]
         | 
| 123 97 | 
             
                  end
         | 
| 124 98 |  | 
| 125 99 | 
             
                  alias source string
         | 
| 126 100 |  | 
| 101 | 
            +
                  def quirks_mode?
         | 
| 102 | 
            +
                    !!@quirks_mode
         | 
| 103 | 
            +
                  end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                  def reset
         | 
| 106 | 
            +
                    super
         | 
| 107 | 
            +
                    @current_nesting = 0
         | 
| 108 | 
            +
                  end
         | 
| 109 | 
            +
             | 
| 127 110 | 
             
                  # Parses the current JSON string _source_ and returns the complete data
         | 
| 128 111 | 
             
                  # structure as a result.
         | 
| 129 112 | 
             
                  def parse
         | 
| 130 113 | 
             
                    reset
         | 
| 131 114 | 
             
                    obj = nil
         | 
| 132 | 
            -
                     | 
| 133 | 
            -
                       | 
| 134 | 
            -
                       | 
| 135 | 
            -
             | 
| 136 | 
            -
                         | 
| 137 | 
            -
                        obj = parse_object
         | 
| 138 | 
            -
                      when scan(ARRAY_OPEN)
         | 
| 139 | 
            -
                        obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
         | 
| 140 | 
            -
                        @current_nesting = 1
         | 
| 141 | 
            -
                        obj = parse_array
         | 
| 142 | 
            -
                      when skip(IGNORE)
         | 
| 143 | 
            -
                        ;
         | 
| 115 | 
            +
                    if @quirks_mode
         | 
| 116 | 
            +
                      while !eos? && skip(IGNORE)
         | 
| 117 | 
            +
                      end
         | 
| 118 | 
            +
                      if eos?
         | 
| 119 | 
            +
                        raise ParserError, "source did not contain any JSON!"
         | 
| 144 120 | 
             
                      else
         | 
| 145 | 
            -
                         | 
| 121 | 
            +
                        obj = parse_value
         | 
| 122 | 
            +
                        obj == UNPARSED and raise ParserError, "source did not contain any JSON!"
         | 
| 146 123 | 
             
                      end
         | 
| 124 | 
            +
                    else
         | 
| 125 | 
            +
                      until eos?
         | 
| 126 | 
            +
                        case
         | 
| 127 | 
            +
                        when scan(OBJECT_OPEN)
         | 
| 128 | 
            +
                          obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
         | 
| 129 | 
            +
                          @current_nesting = 1
         | 
| 130 | 
            +
                          obj = parse_object
         | 
| 131 | 
            +
                        when scan(ARRAY_OPEN)
         | 
| 132 | 
            +
                          obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
         | 
| 133 | 
            +
                          @current_nesting = 1
         | 
| 134 | 
            +
                          obj = parse_array
         | 
| 135 | 
            +
                        when skip(IGNORE)
         | 
| 136 | 
            +
                          ;
         | 
| 137 | 
            +
                        else
         | 
| 138 | 
            +
                          raise ParserError, "source '#{peek(20)}' not in JSON!"
         | 
| 139 | 
            +
                        end
         | 
| 140 | 
            +
                      end
         | 
| 141 | 
            +
                      obj or raise ParserError, "source did not contain any JSON!"
         | 
| 147 142 | 
             
                    end
         | 
| 148 | 
            -
                    obj or raise ParserError, "source did not contain any JSON!"
         | 
| 149 143 | 
             
                    obj
         | 
| 150 144 | 
             
                  end
         | 
| 151 145 |  | 
| 152 146 | 
             
                  private
         | 
| 153 147 |  | 
| 148 | 
            +
                  def determine_encoding(source)
         | 
| 149 | 
            +
                    if defined?(::Encoding)
         | 
| 150 | 
            +
                      if source.encoding == ::Encoding::ASCII_8BIT
         | 
| 151 | 
            +
                        b = source[0, 4].bytes.to_a
         | 
| 152 | 
            +
                        source =
         | 
| 153 | 
            +
                          case
         | 
| 154 | 
            +
                          when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
         | 
| 155 | 
            +
                            source.dup.force_encoding(::Encoding::UTF_32BE).encode!(::Encoding::UTF_8)
         | 
| 156 | 
            +
                          when b.size >= 4 && b[0] == 0 && b[2] == 0
         | 
| 157 | 
            +
                            source.dup.force_encoding(::Encoding::UTF_16BE).encode!(::Encoding::UTF_8)
         | 
| 158 | 
            +
                          when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
         | 
| 159 | 
            +
                            source.dup.force_encoding(::Encoding::UTF_32LE).encode!(::Encoding::UTF_8)
         | 
| 160 | 
            +
                          when b.size >= 4 && b[1] == 0 && b[3] == 0
         | 
| 161 | 
            +
                            source.dup.force_encoding(::Encoding::UTF_16LE).encode!(::Encoding::UTF_8)
         | 
| 162 | 
            +
                          else
         | 
| 163 | 
            +
                            source.dup
         | 
| 164 | 
            +
                          end
         | 
| 165 | 
            +
                      else
         | 
| 166 | 
            +
                        source = source.encode(::Encoding::UTF_8)
         | 
| 167 | 
            +
                      end
         | 
| 168 | 
            +
                      source.force_encoding(::Encoding::ASCII_8BIT)
         | 
| 169 | 
            +
                    else
         | 
| 170 | 
            +
                      b = source
         | 
| 171 | 
            +
                      source =
         | 
| 172 | 
            +
                        case
         | 
| 173 | 
            +
                        when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
         | 
| 174 | 
            +
                          JSON.iconv('utf-8', 'utf-32be', b)
         | 
| 175 | 
            +
                        when b.size >= 4 && b[0] == 0 && b[2] == 0
         | 
| 176 | 
            +
                          JSON.iconv('utf-8', 'utf-16be', b)
         | 
| 177 | 
            +
                        when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
         | 
| 178 | 
            +
                          JSON.iconv('utf-8', 'utf-32le', b)
         | 
| 179 | 
            +
                        when b.size >= 4 && b[1] == 0 && b[3] == 0
         | 
| 180 | 
            +
                          JSON.iconv('utf-8', 'utf-16le', b)
         | 
| 181 | 
            +
                        else
         | 
| 182 | 
            +
                          b
         | 
| 183 | 
            +
                        end
         | 
| 184 | 
            +
                    end
         | 
| 185 | 
            +
                    source
         | 
| 186 | 
            +
                  end
         | 
| 187 | 
            +
             | 
| 154 188 | 
             
                  # Unescape characters in strings.
         | 
| 155 189 | 
             
                  UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
         | 
| 156 190 | 
             
                  UNESCAPE_MAP.update({
         | 
| @@ -162,12 +196,12 @@ module JSON | |
| 162 196 | 
             
                    ?n  => "\n",
         | 
| 163 197 | 
             
                    ?r  => "\r",
         | 
| 164 198 | 
             
                    ?t  => "\t",
         | 
| 165 | 
            -
                    ?u  => nil, | 
| 199 | 
            +
                    ?u  => nil,
         | 
| 166 200 | 
             
                  })
         | 
| 167 201 |  | 
| 168 202 | 
             
                  EMPTY_8BIT_STRING = ''
         | 
| 169 203 | 
             
                  if ::String.method_defined?(:encode)
         | 
| 170 | 
            -
                    EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT | 
| 204 | 
            +
                    EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT
         | 
| 171 205 | 
             
                  end
         | 
| 172 206 |  | 
| 173 207 | 
             
                  def parse_string
         | 
    
        data/lib/json/version.rb
    CHANGED
    
    
    
        data/tests/test_json.rb
    CHANGED
    
    | @@ -104,6 +104,42 @@ class TC_JSON < Test::Unit::TestCase | |
| 104 104 | 
             
                assert_equal({ "a" => 0.23 }, parse('  {  "a"  :  0.23  }  '))
         | 
| 105 105 | 
             
              end
         | 
| 106 106 |  | 
| 107 | 
            +
              def test_parse_json_primitive_values
         | 
| 108 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('') }
         | 
| 109 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('', :quirks_mode => true) }
         | 
| 110 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('  /* foo */ ') }
         | 
| 111 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('  /* foo */ ', :quirks_mode => true) }
         | 
| 112 | 
            +
                parser = JSON::Parser.new('null')
         | 
| 113 | 
            +
                assert_equal false, parser.quirks_mode?
         | 
| 114 | 
            +
                assert_raise(JSON::ParserError) { parser.parse }
         | 
| 115 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('null') }
         | 
| 116 | 
            +
                assert_equal nil, JSON.parse('null', :quirks_mode => true)
         | 
| 117 | 
            +
                parser = JSON::Parser.new('null', :quirks_mode => true)
         | 
| 118 | 
            +
                assert_equal true, parser.quirks_mode?
         | 
| 119 | 
            +
                assert_equal nil, parser.parse
         | 
| 120 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('false') }
         | 
| 121 | 
            +
                assert_equal false, JSON.parse('false', :quirks_mode => true)
         | 
| 122 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('true') }
         | 
| 123 | 
            +
                assert_equal true, JSON.parse('true', :quirks_mode => true)
         | 
| 124 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('23') }
         | 
| 125 | 
            +
                assert_equal 23, JSON.parse('23', :quirks_mode => true)
         | 
| 126 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('1') }
         | 
| 127 | 
            +
                assert_equal 1, JSON.parse('1', :quirks_mode => true)
         | 
| 128 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('3.141') }
         | 
| 129 | 
            +
                assert_in_delta 3.141, JSON.parse('3.141', :quirks_mode => true), 1E-3
         | 
| 130 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('18446744073709551616') }
         | 
| 131 | 
            +
                assert_equal 2 ** 64, JSON.parse('18446744073709551616', :quirks_mode => true)
         | 
| 132 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('"foo"') }
         | 
| 133 | 
            +
                assert_equal 'foo', JSON.parse('"foo"', :quirks_mode => true)
         | 
| 134 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('NaN', :allow_nan => true) }
         | 
| 135 | 
            +
                assert JSON.parse('NaN', :quirks_mode => true, :allow_nan => true).nan?
         | 
| 136 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('Infinity', :allow_nan => true) }
         | 
| 137 | 
            +
                assert JSON.parse('Infinity', :quirks_mode => true, :allow_nan => true).infinite?
         | 
| 138 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('-Infinity', :allow_nan => true) }
         | 
| 139 | 
            +
                assert JSON.parse('-Infinity', :quirks_mode => true, :allow_nan => true).infinite?
         | 
| 140 | 
            +
                assert_raise(JSON::ParserError) { JSON.parse('[ 1, ]', :quirks_mode => true) }
         | 
| 141 | 
            +
              end
         | 
| 142 | 
            +
             | 
| 107 143 | 
             
              if Array.method_defined?(:permutation)
         | 
| 108 144 | 
             
                def test_parse_more_complex_arrays
         | 
| 109 145 | 
             
                  a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
         | 
| @@ -150,7 +186,7 @@ class TC_JSON < Test::Unit::TestCase | |
| 150 186 | 
             
                assert_equal(@ary,
         | 
| 151 187 | 
             
                  parse('[[1],["foo"],[3.14],[47.11e+2],[2718.0E-3],[null],[[1,-2,3]]'\
         | 
| 152 188 | 
             
                  ',[false],[true]]'))
         | 
| 153 | 
            -
                assert_equal(@ary, parse(%Q{   [   [1] , ["foo"]  ,  [3.14] \t ,  [47.11e+2] | 
| 189 | 
            +
                assert_equal(@ary, parse(%Q{   [   [1] , ["foo"]  ,  [3.14] \t ,  [47.11e+2]\s
         | 
| 154 190 | 
             
                  , [2718.0E-3 ],\r[ null] , [[1, -2, 3 ]], [false ],[ true]\n ]  }))
         | 
| 155 191 | 
             
              end
         | 
| 156 192 |  | 
| @@ -406,4 +442,19 @@ EOT | |
| 406 442 | 
             
                json5 = JSON([orig = 1 << 64])
         | 
| 407 443 | 
             
                assert_equal orig, JSON[json5][0]
         | 
| 408 444 | 
             
              end
         | 
| 445 | 
            +
             | 
| 446 | 
            +
              if defined?(JSON::Ext::Parser)
         | 
| 447 | 
            +
                def test_allocate
         | 
| 448 | 
            +
                  parser = JSON::Ext::Parser.new("{}")
         | 
| 449 | 
            +
                  assert_raise(TypeError, '[ruby-core:35079]') {parser.__send__(:initialize, "{}")}
         | 
| 450 | 
            +
                  parser = JSON::Ext::Parser.allocate
         | 
| 451 | 
            +
                  assert_raise(TypeError, '[ruby-core:35079]') {parser.source}
         | 
| 452 | 
            +
                end
         | 
| 453 | 
            +
              end
         | 
| 454 | 
            +
             | 
| 455 | 
            +
              def test_argument_encoding
         | 
| 456 | 
            +
                source = "{}".force_encoding("ascii-8bit")
         | 
| 457 | 
            +
                JSON::Parser.new(source)
         | 
| 458 | 
            +
                assert_equal Encoding::ASCII_8BIT, source.encoding
         | 
| 459 | 
            +
              end if defined?(Encoding::ASCII_8BIT)
         | 
| 409 460 | 
             
            end
         | 
    
        data/tests/test_json_addition.rb
    CHANGED
    
    | @@ -3,7 +3,9 @@ | |
| 3 3 |  | 
| 4 4 | 
             
            require 'test/unit'
         | 
| 5 5 | 
             
            require File.join(File.dirname(__FILE__), 'setup_variant')
         | 
| 6 | 
            -
             | 
| 6 | 
            +
            require 'json/add/core'
         | 
| 7 | 
            +
            require 'json/add/complex'
         | 
| 8 | 
            +
            require 'json/add/rational'
         | 
| 7 9 | 
             
            require 'date'
         | 
| 8 10 |  | 
| 9 11 | 
             
            class TC_JSONAddition < Test::Unit::TestCase
         | 
| @@ -19,7 +21,7 @@ class TC_JSONAddition < Test::Unit::TestCase | |
| 19 21 | 
             
                def ==(other)
         | 
| 20 22 | 
             
                  a == other.a
         | 
| 21 23 | 
             
                end
         | 
| 22 | 
            -
             | 
| 24 | 
            +
             | 
| 23 25 | 
             
                def self.json_create(object)
         | 
| 24 26 | 
             
                  new(*object['args'])
         | 
| 25 27 | 
             
                end
         | 
| @@ -164,4 +166,9 @@ class TC_JSONAddition < Test::Unit::TestCase | |
| 164 166 | 
             
                d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(12,24))
         | 
| 165 167 | 
             
                assert_equal d, JSON.parse(d.to_json)
         | 
| 166 168 | 
             
              end
         | 
| 169 | 
            +
             | 
| 170 | 
            +
              def test_rational_complex
         | 
| 171 | 
            +
                assert_equal Rational(2, 9), JSON(JSON(Rational(2, 9)))
         | 
| 172 | 
            +
                assert_equal Complex(2, 9), JSON(JSON(Complex(2, 9)))
         | 
| 173 | 
            +
              end
         | 
| 167 174 | 
             
            end
         | 
    
        data/tests/test_json_generate.rb
    CHANGED
    
    | @@ -50,6 +50,7 @@ EOT | |
| 50 50 | 
             
                parsed_json = parse(json)
         | 
| 51 51 | 
             
                assert_equal({"1"=>2}, parsed_json)
         | 
| 52 52 | 
             
                assert_raise(GeneratorError) { generate(666) }
         | 
| 53 | 
            +
                assert_equal '666', generate(666, :quirks_mode => true)
         | 
| 53 54 | 
             
              end
         | 
| 54 55 |  | 
| 55 56 | 
             
              def test_generate_pretty
         | 
| @@ -67,6 +68,7 @@ EOT | |
| 67 68 | 
             
                parsed_json = parse(json)
         | 
| 68 69 | 
             
                assert_equal({"1"=>2}, parsed_json)
         | 
| 69 70 | 
             
                assert_raise(GeneratorError) { pretty_generate(666) }
         | 
| 71 | 
            +
                assert_equal '666', pretty_generate(666, :quirks_mode => true)
         | 
| 70 72 | 
             
              end
         | 
| 71 73 |  | 
| 72 74 | 
             
              def test_fast_generate
         | 
| @@ -79,9 +81,24 @@ EOT | |
| 79 81 | 
             
                parsed_json = parse(json)
         | 
| 80 82 | 
             
                assert_equal({"1"=>2}, parsed_json)
         | 
| 81 83 | 
             
                assert_raise(GeneratorError) { fast_generate(666) }
         | 
| 84 | 
            +
                assert_equal '666', fast_generate(666, :quirks_mode => true)
         | 
| 82 85 | 
             
              end
         | 
| 83 86 |  | 
| 84 | 
            -
             | 
| 87 | 
            +
              def test_own_state
         | 
| 88 | 
            +
                state = State.new
         | 
| 89 | 
            +
                json = generate(@hash, state)
         | 
| 90 | 
            +
                assert_equal(JSON.parse(@json2), JSON.parse(json))
         | 
| 91 | 
            +
                parsed_json = parse(json)
         | 
| 92 | 
            +
                assert_equal(@hash, parsed_json)
         | 
| 93 | 
            +
                json = generate({1=>2}, state)
         | 
| 94 | 
            +
                assert_equal('{"1":2}', json)
         | 
| 95 | 
            +
                parsed_json = parse(json)
         | 
| 96 | 
            +
                assert_equal({"1"=>2}, parsed_json)
         | 
| 97 | 
            +
                assert_raise(GeneratorError) { generate(666, state) }
         | 
| 98 | 
            +
                state.quirks_mode = true
         | 
| 99 | 
            +
                assert state.quirks_mode?
         | 
| 100 | 
            +
                assert_equal '666', generate(666, state)
         | 
| 101 | 
            +
              end
         | 
| 85 102 |  | 
| 86 103 | 
             
              def test_states
         | 
| 87 104 | 
             
                json = generate({1=>2}, nil)
         | 
| @@ -107,6 +124,7 @@ EOT | |
| 107 124 | 
             
                  :allow_nan    => false,
         | 
| 108 125 | 
             
                  :array_nl     => "\n",
         | 
| 109 126 | 
             
                  :ascii_only   => false,
         | 
| 127 | 
            +
                  :quirks_mode  => false,
         | 
| 110 128 | 
             
                  :depth        => 0,
         | 
| 111 129 | 
             
                  :indent       => "  ",
         | 
| 112 130 | 
             
                  :max_nesting  => 19,
         | 
| @@ -122,6 +140,7 @@ EOT | |
| 122 140 | 
             
                  :allow_nan    => false,
         | 
| 123 141 | 
             
                  :array_nl     => "",
         | 
| 124 142 | 
             
                  :ascii_only   => false,
         | 
| 143 | 
            +
                  :quirks_mode  => false,
         | 
| 125 144 | 
             
                  :depth        => 0,
         | 
| 126 145 | 
             
                  :indent       => "",
         | 
| 127 146 | 
             
                  :max_nesting  => 19,
         | 
| @@ -137,6 +156,7 @@ EOT | |
| 137 156 | 
             
                  :allow_nan    => false,
         | 
| 138 157 | 
             
                  :array_nl     => "",
         | 
| 139 158 | 
             
                  :ascii_only   => false,
         | 
| 159 | 
            +
                  :quirks_mode  => false,
         | 
| 140 160 | 
             
                  :depth        => 0,
         | 
| 141 161 | 
             
                  :indent       => "",
         | 
| 142 162 | 
             
                  :max_nesting  => 0,
         | 
| @@ -177,4 +197,17 @@ EOT | |
| 177 197 | 
             
                assert_raises(JSON::NestingError) { ary.to_json(s) }
         | 
| 178 198 | 
             
                assert_equal 19, s.depth
         | 
| 179 199 | 
             
              end
         | 
| 200 | 
            +
             | 
| 201 | 
            +
              def test_gc
         | 
| 202 | 
            +
                bignum_too_long_to_embed_as_string = 1234567890123456789012345
         | 
| 203 | 
            +
                expect = bignum_too_long_to_embed_as_string.to_s
         | 
| 204 | 
            +
                stress, GC.stress = GC.stress, true
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                10.times do |i|
         | 
| 207 | 
            +
                  tmp = bignum_too_long_to_embed_as_string.to_json
         | 
| 208 | 
            +
                  assert_equal expect, tmp
         | 
| 209 | 
            +
                end
         | 
| 210 | 
            +
              ensure
         | 
| 211 | 
            +
                GC.stress = stress
         | 
| 212 | 
            +
              end if GC.respond_to?(:stress=)
         | 
| 180 213 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,12 +1,8 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: json
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              prerelease:  | 
| 5 | 
            -
               | 
| 6 | 
            -
                - 1
         | 
| 7 | 
            -
                - 5
         | 
| 8 | 
            -
                - 3
         | 
| 9 | 
            -
              version: 1.5.3
         | 
| 4 | 
            +
              prerelease: 
         | 
| 5 | 
            +
              version: 1.5.4
         | 
| 10 6 | 
             
            platform: java
         | 
| 11 7 | 
             
            authors: 
         | 
| 12 8 | 
             
              - Daniel Luz
         | 
| @@ -14,8 +10,7 @@ autorequire: | |
| 14 10 | 
             
            bindir: bin
         | 
| 15 11 | 
             
            cert_chain: []
         | 
| 16 12 |  | 
| 17 | 
            -
            date: 2011- | 
| 18 | 
            -
            default_executable: 
         | 
| 13 | 
            +
            date: 2011-08-31 00:00:00 Z
         | 
| 19 14 | 
             
            dependencies: []
         | 
| 20 15 |  | 
| 21 16 | 
             
            description: A JSON implementation as a JRuby extension.
         | 
| @@ -28,66 +23,66 @@ extra_rdoc_files: [] | |
| 28 23 |  | 
| 29 24 | 
             
            files: 
         | 
| 30 25 | 
             
              - lib/json.rb
         | 
| 31 | 
            -
              - lib/json/json.xpm
         | 
| 32 | 
            -
              - lib/json/TrueClass.xpm
         | 
| 33 | 
            -
              - lib/json/version.rb
         | 
| 34 26 | 
             
              - lib/json/Array.xpm
         | 
| 35 27 | 
             
              - lib/json/common.rb
         | 
| 28 | 
            +
              - lib/json/editor.rb
         | 
| 36 29 | 
             
              - lib/json/ext.rb
         | 
| 37 | 
            -
              - lib/json/pure.rb
         | 
| 38 | 
            -
              - lib/json/Key.xpm
         | 
| 39 30 | 
             
              - lib/json/FalseClass.xpm
         | 
| 40 | 
            -
              - lib/json/ | 
| 41 | 
            -
              - lib/json/ | 
| 31 | 
            +
              - lib/json/Hash.xpm
         | 
| 32 | 
            +
              - lib/json/json.xpm
         | 
| 33 | 
            +
              - lib/json/Key.xpm
         | 
| 42 34 | 
             
              - lib/json/NilClass.xpm
         | 
| 35 | 
            +
              - lib/json/Numeric.xpm
         | 
| 36 | 
            +
              - lib/json/pure.rb
         | 
| 43 37 | 
             
              - lib/json/String.xpm
         | 
| 44 | 
            -
              - lib/json/ | 
| 38 | 
            +
              - lib/json/TrueClass.xpm
         | 
| 39 | 
            +
              - lib/json/version.rb
         | 
| 40 | 
            +
              - lib/json/add/complex.rb
         | 
| 45 41 | 
             
              - lib/json/add/core.rb
         | 
| 46 | 
            -
              - lib/json/add/ | 
| 47 | 
            -
              - lib/json/pure/generator.rb
         | 
| 48 | 
            -
              - lib/json/pure/parser.rb
         | 
| 42 | 
            +
              - lib/json/add/rational.rb
         | 
| 49 43 | 
             
              - lib/json/ext/generator.jar
         | 
| 50 44 | 
             
              - lib/json/ext/parser.jar
         | 
| 51 | 
            -
              -  | 
| 52 | 
            -
              -  | 
| 45 | 
            +
              - lib/json/pure/generator.rb
         | 
| 46 | 
            +
              - lib/json/pure/parser.rb
         | 
| 53 47 | 
             
              - tests/setup_variant.rb
         | 
| 54 | 
            -
              - tests/ | 
| 48 | 
            +
              - tests/test_json.rb
         | 
| 55 49 | 
             
              - tests/test_json_addition.rb
         | 
| 56 | 
            -
              - tests/test_json_generate.rb
         | 
| 57 50 | 
             
              - tests/test_json_encoding.rb
         | 
| 58 | 
            -
              - tests/ | 
| 59 | 
            -
              - tests/ | 
| 60 | 
            -
              - tests/ | 
| 51 | 
            +
              - tests/test_json_fixtures.rb
         | 
| 52 | 
            +
              - tests/test_json_generate.rb
         | 
| 53 | 
            +
              - tests/test_json_string_matching.rb
         | 
| 54 | 
            +
              - tests/test_json_unicode.rb
         | 
| 55 | 
            +
              - tests/fixtures/fail1.json
         | 
| 61 56 | 
             
              - tests/fixtures/fail10.json
         | 
| 62 | 
            -
              - tests/fixtures/fail24.json
         | 
| 63 | 
            -
              - tests/fixtures/fail28.json
         | 
| 64 | 
            -
              - tests/fixtures/fail13.json
         | 
| 65 | 
            -
              - tests/fixtures/fail4.json
         | 
| 66 | 
            -
              - tests/fixtures/pass3.json
         | 
| 67 57 | 
             
              - tests/fixtures/fail11.json
         | 
| 68 | 
            -
              - tests/fixtures/fail14.json
         | 
| 69 | 
            -
              - tests/fixtures/fail3.json
         | 
| 70 58 | 
             
              - tests/fixtures/fail12.json
         | 
| 71 | 
            -
              - tests/fixtures/ | 
| 72 | 
            -
              - tests/fixtures/ | 
| 73 | 
            -
              - tests/fixtures/fail20.json
         | 
| 74 | 
            -
              - tests/fixtures/fail8.json
         | 
| 75 | 
            -
              - tests/fixtures/pass2.json
         | 
| 76 | 
            -
              - tests/fixtures/fail5.json
         | 
| 77 | 
            -
              - tests/fixtures/fail1.json
         | 
| 78 | 
            -
              - tests/fixtures/fail25.json
         | 
| 79 | 
            -
              - tests/fixtures/pass17.json
         | 
| 80 | 
            -
              - tests/fixtures/fail7.json
         | 
| 81 | 
            -
              - tests/fixtures/pass26.json
         | 
| 82 | 
            -
              - tests/fixtures/fail21.json
         | 
| 83 | 
            -
              - tests/fixtures/pass1.json
         | 
| 84 | 
            -
              - tests/fixtures/fail23.json
         | 
| 59 | 
            +
              - tests/fixtures/fail13.json
         | 
| 60 | 
            +
              - tests/fixtures/fail14.json
         | 
| 85 61 | 
             
              - tests/fixtures/fail18.json
         | 
| 62 | 
            +
              - tests/fixtures/fail19.json
         | 
| 86 63 | 
             
              - tests/fixtures/fail2.json
         | 
| 64 | 
            +
              - tests/fixtures/fail20.json
         | 
| 65 | 
            +
              - tests/fixtures/fail21.json
         | 
| 87 66 | 
             
              - tests/fixtures/fail22.json
         | 
| 67 | 
            +
              - tests/fixtures/fail23.json
         | 
| 68 | 
            +
              - tests/fixtures/fail24.json
         | 
| 69 | 
            +
              - tests/fixtures/fail25.json
         | 
| 88 70 | 
             
              - tests/fixtures/fail27.json
         | 
| 89 | 
            -
              - tests/fixtures/ | 
| 90 | 
            -
             | 
| 71 | 
            +
              - tests/fixtures/fail28.json
         | 
| 72 | 
            +
              - tests/fixtures/fail3.json
         | 
| 73 | 
            +
              - tests/fixtures/fail4.json
         | 
| 74 | 
            +
              - tests/fixtures/fail5.json
         | 
| 75 | 
            +
              - tests/fixtures/fail6.json
         | 
| 76 | 
            +
              - tests/fixtures/fail7.json
         | 
| 77 | 
            +
              - tests/fixtures/fail8.json
         | 
| 78 | 
            +
              - tests/fixtures/fail9.json
         | 
| 79 | 
            +
              - tests/fixtures/pass1.json
         | 
| 80 | 
            +
              - tests/fixtures/pass15.json
         | 
| 81 | 
            +
              - tests/fixtures/pass16.json
         | 
| 82 | 
            +
              - tests/fixtures/pass17.json
         | 
| 83 | 
            +
              - tests/fixtures/pass2.json
         | 
| 84 | 
            +
              - tests/fixtures/pass26.json
         | 
| 85 | 
            +
              - tests/fixtures/pass3.json
         | 
| 91 86 | 
             
            homepage: http://json-jruby.rubyforge.org/
         | 
| 92 87 | 
             
            licenses: []
         | 
| 93 88 |  | 
| @@ -97,23 +92,21 @@ rdoc_options: [] | |
| 97 92 | 
             
            require_paths: 
         | 
| 98 93 | 
             
              - lib
         | 
| 99 94 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 95 | 
            +
              none: false
         | 
| 100 96 | 
             
              requirements: 
         | 
| 101 97 | 
             
                - - ">="
         | 
| 102 98 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 103 | 
            -
                    segments: 
         | 
| 104 | 
            -
                      - 0
         | 
| 105 99 | 
             
                    version: "0"
         | 
| 106 100 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 101 | 
            +
              none: false
         | 
| 107 102 | 
             
              requirements: 
         | 
| 108 103 | 
             
                - - ">="
         | 
| 109 104 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 110 | 
            -
                    segments: 
         | 
| 111 | 
            -
                      - 0
         | 
| 112 105 | 
             
                    version: "0"
         | 
| 113 106 | 
             
            requirements: []
         | 
| 114 107 |  | 
| 115 108 | 
             
            rubyforge_project: json-jruby
         | 
| 116 | 
            -
            rubygems_version: 1. | 
| 109 | 
            +
            rubygems_version: 1.8.9
         | 
| 117 110 | 
             
            signing_key: 
         | 
| 118 111 | 
             
            specification_version: 3
         | 
| 119 112 | 
             
            summary: JSON implementation for JRuby
         | 
    
        data/lib/json/add/rails.rb
    DELETED
    
    | @@ -1,8 +0,0 @@ | |
| 1 | 
            -
            # This file used to implementations of rails custom objects for
         | 
| 2 | 
            -
            # serialisation/deserialisation and is obsoleted now.
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
         | 
| 5 | 
            -
              require 'json'
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            $DEBUG and warn "required json/add/rails which is obsolete now!"
         |