Skip to content

Commit 7f1267b

Browse files
committed
Fix json-pure's Object#to_json to accept non state arguments
Fix: #573
1 parent d373116 commit 7f1267b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGES.md

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

33
* Numerous performance optimizations in `JSON.generate` and `JSON.dump`.
4+
* Fix json-pure's `Object#to_json` to accept non state arguments
45
* Fix multiline comment support in `json-pure`.
56
* Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string.
67
* Fix `String#to_json` to raise on invalid encoding in `json-pure`.

lib/json/pure/generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ module Object
378378
# Converts this object to a string (calling #to_s), converts
379379
# it to a JSON string, and returns the result. This is a fallback, if no
380380
# special method #to_json was defined for some object.
381-
def to_json(generator_state)
382-
if generator_state.strict?
381+
def to_json(state = nil, *)
382+
if state && State.from_state(state).strict?
383383
raise GeneratorError, "#{self.class} not allowed in JSON"
384384
else
385385
to_s.to_json

0 commit comments

Comments
 (0)