-
Notifications
You must be signed in to change notification settings - Fork 32
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
jrjackson improperly dumps BSON::ObjectId #42
Comments
@cheald - I hope that this issue, which I leave open for this exact problem, explains my position. You could use a different adapter in multi_son. The standard Json gem has java extensions that are almost as good now days. |
I actually saw the require 'mongo'
require 'jrjackson'
module ::BSON
class ObjectId
def to_json_data
to_s
end
end
end
id = BSON::ObjectId.new
JrJackson::Json.dump({_id: id})
# => "{\"_id\":[86,5,143,203,47,144,169,173,39,236,44,187]}"
id.to_json_data
# => "56058fcb2f90a9ad27ec2cbb" I see that you opened an issue to promote I needed to use not-the-standard JSON lib because of an issue like this one - it still doesn't properly handle invalid UTF-8, while JrJackson and Gson do. I ended up swapping to Gson and all is fine now, but I'd like to be able to use JrJackson, as well! Is it fair to leave this ticket open until #43 is closed? |
fixed in v0.3.5 @cheald - FYI HTH |
Thanks! |
Using jrjackson 0.3.4 and multi_json:
BSON::ObjectId defines both #to_a and #to_json. AnySerializer prefers to_a over to_json, which results in object IDs being dumped as byte arrays rather than hex strings.
It seems incorrect that AnySerializer should prefer anything over to_json, since that should be canonically what the representation of the object should be, no?
Repro:
The text was updated successfully, but these errors were encountered: