Skip to content

Commit 9039ee7

Browse files
committed
Emit a deprecation warning when passing quirks_mode.
Ideally we'd deprecate all unknown options but it's tricky.
1 parent dbe0991 commit 9039ee7

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Unreleased
44

5+
* Emit a deprecation warning for the outdated `quirks_mode: true` argument.
56
* Emit a deprecation for `JSON.dump` positional `limit` argument.
67

78
### 2026-07-31 (2.21.2)

lib/json/common.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ def to_json(state = nil, *)
360360
# JSON.parse('')
361361
#
362362
def parse(source, opts = nil)
363+
if opts&.key?(:quirks_mode)
364+
deprecation_warning("The `quirks_mode` option was removed since json 2.0 and has no effect. It will raise an error on json 3.0")
365+
end
363366
opts = ParserOptions.prepare(opts) unless opts.nil?
364367
Parser.parse(source, opts)
365368
end
@@ -451,6 +454,9 @@ def generate(obj, opts = nil)
451454
if State === opts
452455
opts.generate(obj)
453456
else
457+
if opts&.key?(:quirks_mode)
458+
deprecation_warning("The `quirks_mode` option was removed since json 2.0 and has no effect. It will raise an error on json 3.0")
459+
end
454460
State.generate(obj, opts, nil)
455461
end
456462
end

0 commit comments

Comments
 (0)