Protobuf: js-field genereted by protoc NOT respect definition in .proto file && always lowercase.

Created on 9 Jul 2019  路  3Comments  路  Source: protocolbuffers/protobuf

Look at "groupId"

message Topic {
string groupId = 1;
Message message = 2;
}

-->>
proto.dawn.Topic.toObject = function(includeInstance, msg) {
var f, obj = {
groupid: jspb.Message.getFieldWithDefault(msg, 1, ""),
message: (f = msg.getMessage()) && proto.dawn.Message.toObject(includeInstance, f)
};

this will result in "groupId" always "groupid", being ugly and bad coding practice.

javascript

Most helpful comment

Current implementation is ugly and don't follow camel specification, so hard to accept by frontend developer.

All 3 comments

Sorry, the spec of toObject is not defined yet. We would like to keep the current implementation as is for now.

Current implementation is ugly and don't follow camel specification, so hard to accept by frontend developer.

I agree. It makes little sense that it does not respect things as defined in the proto.

Was this page helpful?
0 / 5 - 0 ratings