summaryrefslogtreecommitdiff
path: root/ext/json/lib
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-03-27 12:25:08 +0100
committerHiroshi SHIBATA <[email protected]>2025-03-28 12:44:53 +0900
commitec171b4075407d02698a445e169f57fd68a9dcfc ()
tree699ff6c756f7d364cc7896798ba5a1ff04076125 /ext/json/lib
parente8c46f4ca5e6ba2638fbfc81fdb9d141cd88e99a (diff)
[ruby/json] Move `create_addtions` logic in Ruby.
By leveraging the `on_load` callback we can move all this logic out of the parser. Which mean we no longer have to duplicate that logic in both parser and that we'll later be able to extract it entirely from the gem. https://.com/ruby/json/commit/f411ddf1ce
Notes: Merged: https://.com/ruby/ruby/pull/13004
-rw-r--r--ext/json/lib/json/common.rb127
1 files changed, 119 insertions, 8 deletions
@@ -5,6 +5,112 @@ require 'json/version'
module JSON
autoload :GenericObject, 'json/generic_object'
class << self
# :call-seq:
# JSON[object] -> new_array or new_string
@@ -236,9 +342,16 @@ module JSON
# JSON.parse('')
#
def parse(source, opts = nil)
Parser.parse(source, opts)
end
# :call-seq:
# JSON.parse!(source, opts) -> object
#
@@ -251,12 +364,11 @@ module JSON
# which disables checking for nesting depth.
# - Option +allow_nan+, if not provided, defaults to +true+.
def parse!(source, opts = nil)
- options = {
- :max_nesting => false,
- :allow_nan => true
- }
- options.merge!(opts) if opts
- Parser.new(source, options).parse
end
# :call-seq:
@@ -859,10 +971,9 @@ module JSON
options[:strict] = true
end
options[:as_json] = as_json if as_json
- options[:create_additions] = false unless options.key?(:create_additions)
@state = State.new(options).freeze
- @parser_config = Ext::Parser::Config.new(options)
end
# call-seq: