ruby-protobuf / protobuf

A pure ruby implementation of Google's Protocol Buffers
https://github.com/ruby-protobuf
MIT License
462 stars 101 forks source link

Message#to_json should convert field names to lowerCamelCase #408

Closed aslakhellesoy closed 4 years ago

aslakhellesoy commented 4 years ago

According to the Protobuf 3 language guide:

By default proto3 JSON printer should convert the field name to lowerCamelCase and use that as the JSON name.

I know this library isn't currently targetting Proto 3, but is this something you'd be open to a PR for? Backwards compatibility could be maintained by making this an opt-in feature. For example:

json = message.to_json(lower_camel_case: true)
film42 commented 4 years ago

Released in v3.10.3.