ohler55 / oj

Optimized JSON
http://www.ohler.com/oj
MIT License
3.14k stars 251 forks source link

RangeError for Time value #864

Open tobmatth opened 1 year ago

tobmatth commented 1 year ago

I am seeing a RangeError when converting future Time values on Windows. This might be related to #485

irb(main):001:0> date = Time.zone.parse("2040-01-01 00:00:00 UTC")
=> Sun, 01 Jan 2040 00:00:00.000000000 UTC +00:00
irb(main):004:0> { date: date }.to_json
=> "{\"date\":\"2040-01-01T00:00:00.000Z\"}"
irb(main):005:0> Oj.optimize_rails
=> nil
irb(main):006:0> { date: date }.to_json
C:/ruby/versions/3.1.2-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.5.1/lib/active_support/json/encoding.rb:22:in `encode': bignum too big to convert into `long' (RangeError)

Oj 3.14.2 works on Linux (Ruby 3.1.2) Oj 3.14.2 fails on Windows (Ruby 3.1.2)

ohler55 commented 1 year ago

I might need some help testing any potential fix. Are you able to test out a different Oj branch?

tobmatth commented 1 year ago

Sure 👍🏻