Serialize in C ++, deserialze in python?

I have a C ++ application 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 non-serialize this from python:

 import marketdata_pb2 ... md = marketdata_pb2.MarketDataDepth() #what goes here? I don't see a marketdata_pb2.parsefromarray() 
+4
source share
1 answer

You are looking for md.ParseFromString(some_string_of_bytes) . In Python 2.x, "some string of bytes" is str .

https://developers.google.com/protocol-buffers/docs/pythontutorial

+3
source

Source: https://habr.com/ru/post/1434527/


All Articles