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
Range.as_json #4239
Comments
What JSON engine are you using? The JSON gem that ships with ruby does not have this behavior:
|
I'm using Rails 3.1.1 with json 1.6.1 on 1.8.7. I think the problem is caused by active_support/json/encoding.rb: module Enumerable
def as_json(options = nil) #:nodoc:
to_a.as_json(options)
end
end Am I doing something wrong? I vaguely remember that the json gem is only required for 1.8.7, so perhaps this issue goes away with 1.9/Rails 4. Thanks Aaron. |
The problem with calling #to_a is that ranges may be (conceptually) infinite, regardless of whether they respond to succ. |
I agree - that's the bug I'm describing. |
Closing this as #4250 is merged. Thanks! |
This scares me:
Wouldn't this be preferable?
This is an issue in my Rails app, where I occasionally return Ranges as JSON. If the wrong Range slips in there it could crash the app in a nasty, un-debuggable way.
The text was updated successfully, but these errors were encountered: