Cannot serialize object when key has underline #20

Closed
yyfrankyy opened this Issue Nov 2, 2012 · 6 comments

Comments

Projects
None yet
4 participants

Key hello_world in js object need to be changed to helloWorld. weird..

But what if I have another key named helloWorld ?

message {
  required string hello_world = 1;
  required string helloWorld = 2;
}

Having the same issue on protobuf v0.8.6. Any key with an underscore does not get serialized.

Submitted pull request to fix this issue. #21

chrisdew added a commit that referenced this issue Nov 19, 2012

Merge pull request #21 from AdamMagaluk/master
Fix for Bug #20, uses Protobuf FieldDescriptor->name()

Currently the default functionality is to convert all assessors to camel case. "hello_world" would then be accessed by "helloWorld".

Contributor

seishun commented Nov 23, 2012

Using underscore separated names for field names in the convention in protobuf. If your schema defines hello_world and helloWorld in the same message, then you should complain to the author of the schema, because it will break the official Java implementation as well.

@seishun If it broke the official java implementation as well, then that's a problem. Language compatibility is one of the features that protobuf provides, as I known so far, cpp, ruby, python implementations are ok with this.

Owner

chrisdew commented Jul 29, 2013

I'm closing this, as there's been no activity, and @seishun is right.

@chrisdew chrisdew closed this Jul 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment