Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

### 2025-04-24 (2.11.1)

* Add back `JSON.restore`, `JSON.unparse`, `JSON.fast_unparse` and `JSON.pretty_unparse`.
These were deprecated 16 years ago, but never emited warnings, only undocumented, so are
still used by a few gems.

### 2025-04-24 (2.11.0)

* Optimize Integer generation to be ~1.8x faster.
Expand Down
44 changes: 44 additions & 0 deletions lib/json/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,50 @@ def dump(obj, anIO = nil, limit = nil, kwargs = nil)
end
end

# :stopdoc:
# All these were meant to be deprecated circa 2009, but were just set as undocumented
# so usage still exist in the wild.
def unparse(...)
if RUBY_VERSION >= "3.0"
warn "JSON.unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1, category: :deprecated
else
warn "JSON.unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1
end
generate(...)
end
module_function :unparse

def fast_unparse(...)
if RUBY_VERSION >= "3.0"
warn "JSON.fast_unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1, category: :deprecated
else
warn "JSON.fast_unparse is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1
end
generate(...)
end
module_function :fast_unparse

def pretty_unparse(...)
if RUBY_VERSION >= "3.0"
warn "JSON.pretty_unparse is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1, category: :deprecated
else
warn "JSON.pretty_unparse is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1
end
pretty_generate(...)
end
module_function :fast_unparse

def restore(...)
if RUBY_VERSION >= "3.0"
warn "JSON.restore is deprecated and will be removed in json 3.0.0, just use JSON.load", uplevel: 1, category: :deprecated
else
warn "JSON.restore is deprecated and will be removed in json 3.0.0, just use JSON.load", uplevel: 1
end
load(...)
end
module_function :restore
# :startdoc:

# JSON::Coder holds a parser and generator configuration.
#
# module MyApp
Expand Down