Skip to content

Commit

Permalink
Fix json-pure's Object#to_json to accept non state arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Oct 17, 2024
1 parent d373116 commit 7f1267b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changes

* Numerous performance optimizations in `JSON.generate` and `JSON.dump`.
* Fix json-pure's `Object#to_json` to accept non state arguments
* Fix multiline comment support in `json-pure`.
* Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string.
* Fix `String#to_json` to raise on invalid encoding in `json-pure`.
Expand Down
4 changes: 2 additions & 2 deletions lib/json/pure/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ module Object
# Converts this object to a string (calling #to_s), converts
# it to a JSON string, and returns the result. This is a fallback, if no
# special method #to_json was defined for some object.
def to_json(generator_state)
if generator_state.strict?
def to_json(state = nil, *)
if state && State.from_state(state).strict?
raise GeneratorError, "#{self.class} not allowed in JSON"
else
to_s.to_json
Expand Down

0 comments on commit 7f1267b

Please sign in to comment.