Skip to content

Honor as_json and reject disabled strict mode in JSON::Coder - #1093

Merged
byroot merged 1 commit into
ruby:masterfrom
ydah:fix-coder-options
Oct 5, 2026
Merged

byroot merged 1 commit into
ruby:masterfrom
ydah:fix-coder-options

Conversation

@ydah

@ydah ydah commented Oct 5, 2026

Copy link
Copy Markdown
Member

Coder overwrites the as_json option with nil when no block is given. It also silently overrides strict: false.

require "json"

JSON::Coder.new(as_json: ->(object, is_key) { 42 }).dump(Object.new)
# Before: JSON::GeneratorError
# After:  "42"

JSON::Coder.new(strict: false)
# Before: silently enables strict mode
# After:  ArgumentError

Restore the keyword callback while preserving block precedence. Keep Coder's documented strict-mode requirement and reject attempts to disable it.

@ydah
ydah force-pushed the fix-coder-options branch from 8ab0cf1 to da24ef7 Compare October 5, 2026 12:45
@byroot
byroot merged commit b63b4f1 into ruby:master Oct 5, 2026
42 checks passed
@ydah
ydah deleted the fix-coder-options branch October 5, 2026 14:02
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