diff options
author | Jean Boussier <[email protected]> | 2025-03-26 15:19:26 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-03-28 12:44:53 +0900 |
commit | e8c46f4ca5e6ba2638fbfc81fdb9d141cd88e99a () | |
tree | 600722c172e1cded6614c734066c6c8115c53ae9 /ext/json/lib | |
parent | 80a59a62441c0938d0a29fcd5dd95f8024db6ddf (diff) |
[ruby/json] JSON.load invoke the proc callback directly from the parser.
And substitute the return value like `Marshal.load` doesm which I can only assume was the intent. This also open the door to re-implement all the `create_addition` logic in `json/common.rb`. https://.com/ruby/json/commit/73d2137fd3
Notes: Merged: https://.com/ruby/ruby/pull/13004
-rw-r--r-- | ext/json/lib/json/common.rb | 20 |
1 files changed, 5 insertions, 15 deletions
@@ -739,23 +739,13 @@ module JSON if opts[:allow_blank] && (source.nil? || source.empty?) source = 'null' end - result = parse(source, opts) - recurse_proc(result, &proc) if proc - result - end - # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_ - def recurse_proc(result, &proc) # :nodoc: - case result - when Array - result.each { |x| recurse_proc x, &proc } - proc.call result - when Hash - result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc } - proc.call result - else - proc.call result end end # Sets or returns the default options for the JSON.dump method. |