sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

BigDecimal#as_json

A BigDecimal would be naturally represented as a JSON number. Most libraries,
however, parse non-integer JSON numbers directly as floats. Clients using
those libraries would get in general a wrong number and no way to recover
other than manually inspecting the string with the JSON code itself.

That's why a JSON string is returned. The JSON literal is not numeric, but
if the other end knows by contract that the data is supposed to be a
BigDecimal, it still has the chance to post-process the string and get the
real value.

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/object/json.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-BigDecimal-as_json-for-pr


# Commit to git

git add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/object/json.rbgit commit -m "better docs for BigDecimal#as_json"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-BigDecimal-as_json-for-pr

hub pull-request


# Celebrate!