You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by "Rokita, Greg" <gr...@edmunds.com> on 2010/02/12 04:19:00 UTC

convert form binary to json

Is there a way to generically convert TBinaryProtocol byte array to TJsonProtocol given a reference to Iface  for that message?  (in Java)

I looked at the code but the serialization requires me to have concrete TBase object.  All I have is Iface interface.

I'm sure someone needed that before for debugging...


Re: convert form binary to json

Posted by David Reiss <dr...@facebook.com>.
You can do this in C++ with the TProtocolTap class.  See
contrib/thrift_dump.cpp for an example of how to do this.  (It converts
from binary to TDebugProtocol.)  TProtocolTap is a pretty simple class.
It probably wouldn't be to hard to implement it in Java.

Rokita, Greg wrote:
> Is there a way to generically convert TBinaryProtocol byte array to TJsonProtocol given a reference to Iface  for that message?  (in Java)
> 
> I looked at the code but the serialization requires me to have concrete TBase object.  All I have is Iface interface.
> 
> I'm sure someone needed that before for debugging...
> 

Re: convert form binary to json

Posted by Bryan Duxbury <br...@rapleaf.com>.
Are you trying to debug some sort of deserialization issue, or do you want
to convert for some other reason? Note that you can determine the actual
TBase object you need to deserialize without too much difficulty - it's in
the class that contains the Iface.

When I need to debug serialized stuff, I tend to just hand-parse it. I'm
probably a bit of an exception though, since I'm a Java-protocol hacker :)

On Thu, Feb 11, 2010 at 7:19 PM, Rokita, Greg <gr...@edmunds.com> wrote:

> Is there a way to generically convert TBinaryProtocol byte array to
> TJsonProtocol given a reference to Iface  for that message?  (in Java)
>
> I looked at the code but the serialization requires me to have concrete
> TBase object.  All I have is Iface interface.
>
> I'm sure someone needed that before for debugging...
>
>