Skip to content

Instantly share code, notes, and snippets.

@tamtam180
Last active January 15, 2016 03:41
Show Gist options
  • Save tamtam180/04ce72f25760e3c46d34 to your computer and use it in GitHub Desktop.
Save tamtam180/04ce72f25760e3c46d34 to your computer and use it in GitHub Desktop.
Oj
irb(main):007:0* require 'Oj'
=> false
irb(main):008:0> Oj.load('{"x": 1e-314}')
=> {"x"=>0.0}
irb(main):009:0> Oj.default_options = { :bigdecimal_load => :bigdecimal }
=> {:bigdecimal_load=>:bigdecimal}
irb(main):010:0> Oj.load('{"x": 1e-314}')
=> {"x"=>#<BigDecimal:7fd73a87d188,'0.1E-313',9(18)>}
irb(main):007:0* require 'Oj'
=> false
irb(main):004:0> Oj.load('{"x":999999999999999999999999999999.99999}')
=> {"x"=>#<BigDecimal:7fccea0f4ec0,'0.9999999999 9999999999 9999999999 99999E30',45(45)>}
irb(main):005:0> Oj.default_options = { :bigdecimal_load => :float }
=> {:bigdecimal_load=>:float}
irb(main):006:0> Oj.load('{"x":999999999999999999999999999999.99999}')
=> {"x"=>1.0e+30}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment