I'm researching the possibility of serializing data via Google Protocol Buffers on a C++ application, sending the data to a JavaScript application, and deserializing the data for use by the JavaScript application. However, with no "ParseFromString()" function capability I'm not sure how this can be done and can't find any clear answer or example. How can this be done?
I'm using google-protobuf and proto3. I haven't tried much... truth is that I don't know where to even start. I would like to provide a MCVE but don't know how to with what I'm trying to achieve.
I've looked at "deserializeBinary" but I lost typing (deserializeBinary() required an "object" type param) when parsing the data from the received message. I'm using binary-parser for parsing the header from the serialized protocol buffer data.
// var msg == full received message from c++ server
// which consists of 32 bit header
var parser = new Parser()
.uint16("header_val_1")
.uint16("header_val_2")
.string("msg_payload", {
zeroTerminated: true
});
var msgObj = parser.parse(msg);
var payloadData = msgObj.msg_payload;
var newData = ProtoMsg.SpecialData.deserializeBinary(payloadData);
// throws type error (expects 'object')
I'd expect newData to be populated with the expected SpecialData message type so that it can checked for specific data points.
newData.getLength()
However that I can't get past the error and even then I'm not sure if I'm doing this right.