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

Getting TypeError: wrong argument type JSON::Pure::Generator::State (expected Data) from json/pure when called Hash.to_json with Fixnum data #198

Closed
johnvoloski opened this issue Mar 7, 2014 · 2 comments

Comments

@johnvoloski
Copy link

some_hash = { 'jsonrpc' => 'xxxx', 'jsonversion' => 1 }
some_hash.to_json

wrong argument type JSON::Pure::Generator::State(expected Data) (TypeError)

I solved the problem implementing:
lib/json/pure/generator.rb:413

class Fixnum
  def to_json(*) to_s end
end
@flori
Copy link
Member

flori commented Mar 10, 2014

Fixnum already has an implementation of the to_json method via its superclass Integer.

I cannot reproduce your problem. Can you provide more information like json and ruby versions, platforms, etc., and the value of JSON.state ? Does the problem crop up, if you only require json or do you need to require anything else?

@byroot
Copy link
Member

byroot commented Oct 17, 2024

Duplicate of #186

@byroot byroot marked this as a duplicate of #186 Oct 17, 2024
@byroot byroot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
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 a pull request may close this issue.

3 participants