dewski/json_builder

Decimals in hashes disappear.

woodardj opened this issue · 3 comments

When adding a hash including a floating point value to the generator, it disappears in the resulting json.

Not the same as issue 2!

> h = {"hello" => 1.4}
=> {"hello"=>1.4}
> json = JSONBuilder::Generator.new 
=> {}
> json.data h
=> ["\"data\": {\"hello\": }"]
> json.compile!
=> "{\"data\": {\"hello\": }}"

Which version of the gem are you using? This is an older version of the gem that had quite a few bugs like this. I'd suggest upgrading to json_builder 3.1.0.

irb(main):007:0> JSONBuilder::Compiler.generate do
irb(main):008:1*   data({"hello" => 1.4})
irb(main):009:1> end
=> "{\"data\": {\"hello\":1.4}}"

Nope, you're right! Miscommunication with my team around our Gemfile. Thanks for the quick reply!

No problem, let me know if you need any more help!