Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json 1.8.3: json/pure fails generating Fixnum #269

Closed
atombrenner opened this issue Feb 6, 2016 · 2 comments
Closed

json 1.8.3: json/pure fails generating Fixnum #269

atombrenner opened this issue Feb 6, 2016 · 2 comments

Comments

@atombrenner
Copy link

The following snippet raises an exception when generating to_json with the pure parser.

require 'json/pure'
JSON('{"test": 5}').to_json

The C parser works like expected. If you change 5 to 5.1 it works again. Seems to be a wrong type check inside the pure generator.

Stacktrace:
/var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:366:in to_json': wrong argument type JSON::Pure::Generator::State (expected JSON/Generator/State) (TypeError)
from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:366:in block in json_transform' from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:359:in each'
from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:359:in json_transform' from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:341:in to_json'`

@atombrenner atombrenner changed the title json 1.8.3: json/pure fails generating integers json 1.8.3: json/pure fails generating Fixnum Feb 6, 2016
@atombrenner
Copy link
Author

I looked into generator.rb and couldn't find any kind of type check. So I got back to my code and found out that it required 'aws-sdk' which required 'json'. So to reproduce the issue on irb you need to do this:

Tuxedo:~$ irb
irb(main):001:0> require 'json'
=> true
irb(main):002:0> require 'json/pure'
=> true
irb(main):003:0> JSON('{"test": 5}').to_json
TypeError: wrong argument type JSON::Pure::Generator::State (expected JSON/Generator/State)
    from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:366:in `to_json'
    from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:366:in `block in json_transform'
    from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:359:in `each'
    from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:359:in `json_transform'
    from /var/lib/gems/2.1.0/gems/json-1.8.3/lib/json/pure/generator.rb:341:in `to_json'
    from (irb):3
    from /usr/bin/irb:11:in `<main>'
irb(main):004:0> 5.to_json
TypeError: wrong argument type JSON::Pure::Generator::State (expected JSON/Generator/State)
    from (irb):4:in `to_json'
    from (irb):4
    from /usr/bin/irb:11:in `<main>'
irb(main):005:0> puts 5.1.to_json
5.1
=> nil

@marcandre
Copy link
Member

Sorry for the late feedback.

This is fixed in 2.3.0 and can be closed.

@hsbt hsbt closed this as completed Jun 30, 2020
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

No branches or pull requests

3 participants