json 2.19.1 → 2.20.0

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.
@@ -48,7 +48,7 @@ module JSON
48
48
  SCRIPT_SAFE_ESCAPE_PATTERN = /[\/"\\\x0-\x1f\u2028-\u2029]/
49
49
 
50
50
  def self.native_type?(value) # :nodoc:
51
- (false == value || true == value || nil == value || String === value || Array === value || Hash === value || Integer === value || Float === value || Fragment === value)
51
+ (false == value || true == value || nil == value || String === value || Symbol === value || Array === value || Hash === value || Integer === value || Float === value || Fragment === value)
52
52
  end
53
53
 
54
54
  def self.native_key?(key) # :nodoc:
@@ -307,6 +307,9 @@ module JSON
307
307
  if !opts.key?(:max_nesting) # defaults to 100
308
308
  @max_nesting = 100
309
309
  elsif opts[:max_nesting]
310
+ unless opts[:max_nesting].is_a?(Integer)
311
+ raise TypeError, ":max_nesting must be an Integer, got: #{opts[:max_nesting].class}"
312
+ end
310
313
  @max_nesting = opts[:max_nesting]
311
314
  else
312
315
  @max_nesting = 0
@@ -517,11 +520,11 @@ module JSON
517
520
 
518
521
  if empty?
519
522
  state.depth -= 1
520
- return '{}'
523
+ return +'{}'
521
524
  end
522
525
 
523
526
  delim = ",#{state.object_nl}"
524
- result = +"{#{state.object_nl}"
527
+ result = "{#{state.object_nl}"
525
528
  first = true
526
529
  key_type = nil
527
530
  indent = !state.object_nl.empty?
@@ -558,7 +561,7 @@ module JSON
558
561
  raise TypeError, "#{key.class}#to_s returns an instance of #{key_str.class}, expected a String"
559
562
  end
560
563
 
561
- result = +"#{result}#{key_json}#{state.space_before}:#{state.space}"
564
+ result = "#{result}#{key_json}#{state.space_before}:#{state.space}"
562
565
  if state.strict? && !Generator.native_type?(value)
563
566
  if state.as_json
564
567
  value = state.as_json.call(value, false)
@@ -609,7 +612,7 @@ module JSON
609
612
 
610
613
  if empty?
611
614
  state.depth -= 1
612
- return '[]'
615
+ return +'[]'
613
616
  end
614
617
 
615
618
  result = '['.dup
@@ -734,17 +737,17 @@ module JSON
734
737
 
735
738
  module TrueClass
736
739
  # Returns a JSON string for true: 'true'.
737
- def to_json(*) 'true' end
740
+ def to_json(*) +'true' end
738
741
  end
739
742
 
740
743
  module FalseClass
741
744
  # Returns a JSON string for false: 'false'.
742
- def to_json(*) 'false' end
745
+ def to_json(*) +'false' end
743
746
  end
744
747
 
745
748
  module NilClass
746
749
  # Returns a JSON string for nil: 'null'.
747
- def to_json(*) 'null' end
750
+ def to_json(*) +'null' end
748
751
  end
749
752
  end
750
753
  end
data/lib/json/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSON
4
- VERSION = '2.19.1'
4
+ VERSION = '2.20.0'
5
5
  end
data/lib/json.rb CHANGED
@@ -145,11 +145,11 @@ require 'json/common'
145
145
  # # warning: detected duplicate keys in JSON object.
146
146
  # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
147
147
  #
148
- # When set to `+true+`
148
+ # When set to +true+:
149
149
  # # The last value is used.
150
150
  # JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
151
151
  #
152
- # When set to `+false+`, the future default:
152
+ # When set to +false+, the future default:
153
153
  # JSON.parse('{"a": 1, "a":2}') => duplicate key at line 1 column 1 (JSON::ParserError)
154
154
  #
155
155
  # ---
@@ -184,6 +184,20 @@ require 'json/common'
184
184
  #
185
185
  # ---
186
186
  #
187
+ # Option +allow_comments+ (boolean) specifies whether to allow
188
+ # JavaScript style comments (either <tt>// comment</tt> or <tt>/* comment */</tt>);
189
+ # defaults to +false+.
190
+ #
191
+ # When not specified, a deprecation warning is emitted if a comment is encountered.
192
+ #
193
+ # When set to +true+, comments are ignored:
194
+ # JSON.parse('/* comment */ {"a": 1, "a":2}') # => {"a" => 2}
195
+ #
196
+ # When set to +false+, the future default:
197
+ # JSON.parse('/* comment */ {"a": 1, "a":2}') # unexpected character: '/' at line 1 column 1 (JSON::ParserError)
198
+ #
199
+ # ---
200
+ #
187
201
  # Option +allow_control_characters+ (boolean) specifies whether to allow
188
202
  # unescaped ASCII control characters, such as newlines, in strings;
189
203
  # defaults to +false+.
@@ -335,8 +349,8 @@ require 'json/common'
335
349
  # JSON.generate(JSON::MinusInfinity)
336
350
  #
337
351
  # Allow:
338
- # ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity]
339
- # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]'
352
+ # ruby = [Float::NAN, Float::INFINITY, JSON::NaN, JSON::Infinity, JSON::MinusInfinity]
353
+ # JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,NaN,Infinity,-Infinity]'
340
354
  #
341
355
  # ---
342
356
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.1
4
+ version: 2.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -31,9 +31,9 @@ files:
31
31
  - ext/json/ext/parser/parser.c
32
32
  - ext/json/ext/simd/conf.rb
33
33
  - ext/json/ext/simd/simd.h
34
+ - ext/json/ext/vendor/fast_float_parser.h
34
35
  - ext/json/ext/vendor/fpconv.c
35
36
  - ext/json/ext/vendor/jeaiii-ltoa.h
36
- - ext/json/ext/vendor/ryu.h
37
37
  - json.gemspec
38
38
  - lib/json.rb
39
39
  - lib/json/add/bigdecimal.rb
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 4.0.3
87
+ rubygems_version: 4.0.12
88
88
  specification_version: 4
89
89
  summary: JSON Implementation for Ruby
90
90
  test_files: []