Open billmarczak opened 13 years ago
I'm not sure there is an easy way to workaround this:
MessagePack.unpack(MessagePack.pack(:foo)).class
=> String
To fix this particular problem, we could teach MessagePack how to handle Symbols. We could also switch to a different serialization library (e.g., builtin Marshal).
I looked into this a little bit, and filed a MsgPack bug: http://redmine.msgpack.org/issues/5
I'm not sure there is actually a very clean way to fix this, short of (a) MsgPack bugfix (b) explicitly sending some sort of flag in the serialized data to indicate that a given value is a Symbol.
I've run into this problem now, too. Let me suggest BERT as a MessagePack replacement. It has an available ruby implementation. I believe github uses it for their data serialisation needs.
$ irb irb(main):001:0> require 'bert' => true irb(main):002:0> BERT.decode(BERT.encode(:symbol)).class => Symbol irb(main):003:0>
Yeah, switching to another serialization framework might make sense. I'm not familiar with BERT, but I'll take a look.
check it:
i'd expect "local: yo sym" and "net: yo sym" to print out. however, what actually prints out is "net: yo str" and "local: yo sym". so not a huge deal, but a minor inconsistency that symbols are converted to strings over the network, but not locally.