I have an application in C++ that serializes a structure using Google Protobuf like this
int len = mdd.ByteSize();
char* buf = (char *)malloc(len);
mdd.SerializeToArray(buf, len);
I want to unserialize this from python:
import marketdata_pb2
...
md = marketdata_pb2.MarketDataDepth()
#what goes here? I don't see a marketdata_pb2.parsefromarray()
You're looking for md.ParseFromString(some_string_of_bytes)
. In Python 2.x "some string of bytes" is a str
.
https://developers.google.com/protocol-buffers/docs/pythontutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With