Skip to content

Fix JSON.unsafe_load with proc argument#849

Merged
byroot merged 2 commits into
ruby:masterfrom
robinetmiller:master
Sep 2, 2025
Merged

Fix JSON.unsafe_load with proc argument#849
byroot merged 2 commits into
ruby:masterfrom
robinetmiller:master

Conversation

@robinetmiller
Copy link
Copy Markdown
Contributor

Commit 73d2137 (released with version 2.11.0) removes JSON.recurse_proc and its the call in JSON.load, opting instead to replace the call with the :on_load option. However, this is not the only instance of recurse_proc, and anyone using JSON.unsafe_load with a proc will receive a NoMethodError.

It would appear that JSON.unsafe_load had no tests whatsoever, causing this failure.

These commits:

  1. Add tests covering JSON.unsafe_load
  2. AlignJSON.unsafe_load with the current behaviour of JSON.load
  3. Update the documentation to show that the proc must return the object, as the examples as is do not work.

@robinetmiller robinetmiller mentioned this pull request Sep 2, 2025
@byroot byroot merged commit 56c0b62 into ruby:master Sep 2, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants