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

Add an option to serialize BigDecimal as String #59

Open
frankwong15 opened this issue Dec 25, 2016 · 2 comments
Open

Add an option to serialize BigDecimal as String #59

frankwong15 opened this issue Dec 25, 2016 · 2 comments

Comments

@frankwong15
Copy link

Rails serialize BigDecimal as String. If we want to use JrJackson as drop in replacement, we need an option to serialize BigDecimal as String.

Test case:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'activesupport'
  gem 'jrjackson'
end

require 'minitest/autorun'

class MyTest < Minitest::Test
  def test_should_be_true
    require 'active_support/core_ext/object/json'
    obj = {number: BigDecimal.new('123.45')}
    assert_equal JSON.dump(obj), JrJackson::Json.dump(obj)
  end
end

Output:

  1) Failure:
MyTest#test_should_be_true [test.rb:15]:
Expected: "{\"number\":\"123.45\"}"
  Actual: "{\"number\":123.45}"
@respire
Copy link

respire commented Mar 13, 2018

Hello @guyboertje , I saw an open PR for this issue. Could you help look at it? it's appreciated that this issue can be resolved. So we don't need to check every column that used BIGINT(8) in our codebase.

@respire
Copy link

respire commented Mar 13, 2018

hello @frankwong15 , it would be great to add another optional option for Bignum, or 64 bits integer. Because browser only supports 53 bits integer. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)

frankwong15 added a commit to frankwong15/jrjackson that referenced this issue Jan 3, 2020
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

No branches or pull requests

2 participants