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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changes

* Add back `JSON::PRETTY_STATE_PROTOTYPE`. This constant was private API but is used by popular gems like `multi_json`.
It now emits a deprecation warning.

### 2025-04-24 (2.11.1)

* Add back `JSON.restore`, `JSON.unparse`, `JSON.fast_unparse` and `JSON.pretty_unparse`.
Expand Down
18 changes: 18 additions & 0 deletions lib/json/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,24 @@ def restore(...)
load(...)
end
module_function :restore

class << self
private

def const_missing(const_name)
case const_name
when :PRETTY_STATE_PROTOTYPE
if RUBY_VERSION >= "3.0"
warn "JSON::PRETTY_STATE_PROTOTYPE is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1, category: :deprecated
else
warn "JSON::PRETTY_STATE_PROTOTYPE is deprecated and will be removed in json 3.0.0, just use JSON.pretty_generate", uplevel: 1
end
state.new(PRETTY_GENERATE_OPTIONS)
else
super
end
end
end
# :startdoc:

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