I havea thrift file that was serialized with TBinaryProtocol. I want to deserialize this file to read it's content. What's the best approach to do it?
I am using thrift:
from thrift.TSerialization import serialize
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
and then I defined the function:
def thrift_to_json(d):
return serialize(d, protocol_factory=TBinaryProtocol())
When I run the above function I get this error msg:
TypeError: TBinaryProtocol.__init__() missing 1 required positional argument: 'trans'
How can I pass the argument trans to the TBinaryProtocol? and what is this trans argument?
Thanks
The missing "trans" tells you that you need a transport, e.g. a file stream that holds the input data.
Thrift separates the endpoint transports (file, socket, http) from the serialization protocol (binary, json, compact) and that's why one needs at least as a minimum some "enpdoint" transport and some protocol.
Useful links: