diff options
author | Florian Frank <flori@ping.de> | 2011-08-29 21:31:33 +0200 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2011-08-29 21:31:33 +0200 |
commit | 2b5de6d03750b113333eded00177b14f8719042e (patch) | |
tree | feb73b6ed464249ef0f004d68ca5f6053ed5311c /lib/json/common.rb | |
parent | fe046d68c5ed88b32b1cf3343babcf367b5cc79f (diff) | |
parent | 86bd839402eae91a1703fdfe6e1ae8267f39f030 (diff) | |
download | json-2b5de6d03750b113333eded00177b14f8719042e.tar.gz |
Merge branch 'quirks-mode'
Diffstat (limited to 'lib/json/common.rb')
-rw-r--r-- | lib/json/common.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb index bc8c952..43e249c 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -198,7 +198,11 @@ module JSON # amount of sanity checks, and the pretty_generate method for some # defaults for pretty output. def generate(obj, opts = nil) - state = SAFE_STATE_PROTOTYPE.dup + if State === opts + state, opts = opts, nil + else + state = SAFE_STATE_PROTOTYPE.dup + end if opts if opts.respond_to? :to_hash opts = opts.to_hash @@ -225,7 +229,11 @@ module JSON # *WARNING*: Be careful not to pass any Ruby data structures with circles as # _obj_ argument because this will cause JSON to go into an infinite loop. def fast_generate(obj, opts = nil) - state = FAST_STATE_PROTOTYPE.dup + if State === opts + state, opts = opts, nil + else + state = FAST_STATE_PROTOTYPE.dup + end if opts if opts.respond_to? :to_hash opts = opts.to_hash @@ -252,7 +260,11 @@ module JSON # The _opts_ argument can be used to configure the generator. See the # generate method for a more detailed explanation. def pretty_generate(obj, opts = nil) - state = PRETTY_STATE_PROTOTYPE.dup + if State === opts + state, opts = opts, nil + else + state = PRETTY_STATE_PROTOTYPE.dup + end if opts if opts.respond_to? :to_hash opts = opts.to_hash |