Created
February 5, 2011 19:25
-
-
Save stefl/812700 to your computer and use it in GitHub Desktop.
Json gem users take note...
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
# Deal with the usual JSON gem idiocy. Guys, come on. I want to serialize an integer, surely this can't be that hard | |
class Fixnum | |
def to_json(options = nil) | |
to_s | |
end | |
end |
Reading that I still don't quite understand why I have to turn an integer into a string to get my very basic datamapper model instance to serialize it's Serial ID. It seems from the spec that you're allowed to have integers... Guess I'm being dumb.
Integers are JSON values, not JSON text. JSON generators are required to output JSON text, which is just objects and arrays. (Yes, it's stupid).
What's the actual code you have that's failing?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alas, it's actually behaving in compliance to the (rather bizarre) spec. See http://www.ietf.org/rfc/rfc4627.txt?number=4627
Quoted:
A JSON text is a serialized object or array.