Created
April 20, 2017 07:52
-
-
Save jsperezg/fbd811230b1aabefab5231efe173119c to your computer and use it in GitHub Desktop.
Serializes numbers with more than 53 bit as strings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fixnum | |
alias_method :default_as_json, :as_json | |
# Serializes long integers as strings. | |
def as_json(options = {}) | |
if self.bit_length > 53 | |
"#{ default_as_json(options) }" | |
else | |
default_as_json(options) | |
end | |
end | |
def to_json(options = {}) | |
as_json(options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment