Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deserialize list of objects using protobuf

I'm building a C# server and python client app with socket communication. The server sends serialized list of objects to client, but I've got no idea (and couldn't find either) how to deserialize a list in python. Any help would be appreciated.

like image 335
Davita Avatar asked Jun 16 '14 19:06

Davita


1 Answers

Allright, I found solution if anyone is interested. The trick is to create a new message type and add original one as repeated. Here's how

message TransactionPackets {
    repeated TransactionPacket packet = 1;
}

message TransactionPacket {
    required int32 trans_id = 1;
    required string user_id = 2;
    required int64 date = 3;
}

Now I can simply deserialize a list of objects by calling TransactionPackets.ParseFromString()

like image 101
Davita Avatar answered Sep 30 '22 16:09

Davita