Closed shargors closed 10 years ago
It returns an array for me.
Node version: v0.10.12 Protobuf Version: v0.8.6
t.proto
message TT {
repeated string str = 1;
optional uint32 uu = 2;
}
test.js
var fs = require('fs');
var util = require('util');
var assert = require('assert');
var Schema = require('protobuf').Schema;
var schema = new Schema(fs.readFileSync('t.desc'))
var tt = schema['TT']
var msg = {str: ['abc', '123'], uu: 23}
var buf = tt.serialize(msg)
var m = tt.parse(buf)
assert(util.isArray(m.str));
Thank you, Adam.
I will try to upgrade to the latest version of Node and perform the same tests. Give me a few days to do that. I will close the issue then.
Stan
Tested with node v0.10.22 and protobuf v 0.8.7 and it works as expected.
Not sure if the problem is in serialization or de-serialization logic but when I send a message with a repeated string field I get back a single string instead of an array. To be more exact, the repeated string field is set by a string array in the outgoing message but I got back a comma-separated string where each comma-separated part is an element of the original string array.
Here is the proto file: message TT { repeated string str = 1; optional uint32 uu = 2; }
Here is a simple test I did in node (v0.10.4): $ node