Msgpack is not supporting date. I just need it to do what json does
which is to stringify dates and pass them along.
So I would like to intercept however its buried in
MessagePackLibrary.java. A little of digging points to what I believe I
need which is to include the following:
so my general question is do I really need to modify the Java code ,
create the gem and install it in or does JRuby also give one a
convenient mechanism to override from Ruby. BTW, do not know if there’s
such a beast as RubyDate but it serves to make my point.
Finally , if the developer of msgpack-jruby is listening would it not be
a reasonable implementation to do what json does so that msgpack can be
plugged in wherever json is being used? That perhaps is not faithful to
the msgpack original implementation but it would be very useful.
Msgpack is not supporting date. I just need it to do what json does which is
to stringify dates and pass them along.
…
so my general question is do I really need to modify the Java code , create
the gem and install it in or does JRuby also give one a convenient mechanism
to override from Ruby. BTW, do not know if there’s such a beast as RubyDate
but it serves to make my point.
Yeah, you probably will have to modify the Java code. JRuby exts (like
C exts) can be implemented more in Ruby or in ways that allow more
customization, but that doesn’t appear to be the case here.
Finally , if the developer of msgpack-jruby is listening would it not be a
reasonable implementation to do what json does so that msgpack can be
plugged in wherever json is being used? That perhaps is not faithful to the
msgpack original implementation but it would be very useful.
Their site has issues , can’t at the moment dig up the docs on the C
version but according to the MRI version there is no support for Date
and
Json itself does not support Date. The MRI version of JSON will turn
dates into a String and include them in the serialization i.e. instead
of crashing.
I can add my to_msgpack , and take the path of least resistance. I"m
guessing they want to stay faithful to the JSON spec.
right, for one in msgpack-jruby to_msgpack was not provided, I had to
use MessagePack.pack and unpack to work the examples. I’m sure a lot of
this is driven by the implementation that is entirely in Java. I don’t
know enough about JRbuy magic yet to reify into Ruby land a Java
construct but now that I think about it, I should at least be able to
add to_msgpack myself to Jruby and then delegate to MessagePack.pack
taking care of stringifying object types not handled by MessagePack i.e.
date/time
wasn’t thinking , the moment you sent the top object to MessagePack ,
the entire graph is out in Java land and they are no recursive hooks
where I could intercept with my Date implementation
I’m the auhor of msgpack-jruby. I made a concious decision not to
support
msgpack’s #to_msgpack, too many gems pollute the global namespace with
their methods and you can so easily add this yourself if you really need
it.
It wouldn’t have helped you to have it anyway, unfortunately, since it
would only make it possible to serialize dates, the deserialization side
wouldn’t know when it should reconstruct a Date instance instead of
something else. You’d need to tag the dates on the serialization side,
and
then a lot of logic on the deserialization side to discover the tagged
values and deserialize them correctly. All of the the custom logic is on
the deserialization side, and outside of MessagePack.
Please report an issue in the msgpack-jruby project if you have feature
requests, suggestions or bugs you’d like to report.
T#
On Mon, Jun 10, 2013 at 6:05 PM, Charles Oliver N.
Get a patch into msgpack-jruby for the additional behavior.
Reimplement that part of msgpack-jruby from Ruby if you can.
Fork the gem and fix it yourself.
If this behavior is different from msgpack-ruby, I’d say #1 is the
best option, followed by #2. If it’s not different, it may still be
logical to include in the JRuby version.
ok, I guess my main surprise is that I would expect that I can simply
substitute msgpack where I am using json i.e. I’m y Ruby code and that’s
not possible.
I"ll get around to entering the request but it seems design decisions
would prevent my wish from coming true.