Open
Description
When I executed the toObject
method on a message with a field marked optional
, that field became the default value like 0
or ""
. I expect it would be undefined
.
I guess it is because the third argument of getFieldWithDefault
is not undefined
.
Since proto3 currently support optional
keyword, when optional
is specified, I think it should be undefined
if it is not given.
proto
syntax = "proto3";
package com.book;
message OptTest {
optional string name = 1;
}
generated toObject
code
proto.com.book.OptTest.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
versions
$ npm list --depth=0 -g
/usr/local/lib
+-- [email protected]
+-- [email protected]
`-- [email protected]
Activity