test.proto:
message test{
repeated int32 history = 1;
}
my nodejs code:
var Schema = require('protobuf').Schema;
var schema = new Schema(fs.readFileSync(test.desc'));
var req_ob = {
hisatory: []
};
var Req = schema['test'];
var s = Req.serialize(req_ob);
console.log("request:" + JSON.stringify(req_ob));
test.proto: message test{ repeated int32 history = 1; }
my nodejs code: var Schema = require('protobuf').Schema; var schema = new Schema(fs.readFileSync(test.desc')); var req_ob = { hisatory: [] }; var Req = schema['test']; var s = Req.serialize(req_ob); console.log("request:" + JSON.stringify(req_ob));
var Res = schema['test']; var r = Req.parse(s);
console.log("response:" + JSON.stringify(r));
console: request:{"hisatory":[]} response:{}
why response is {}, not {"hisatory":[]} ???