You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proto3 JSON specification says that Proto3 JSON parsers are required to accept both the converted lowerCamelCase name and the proto field name.. This seems to mean that, given a message with a field like "my_field", the fromJson method should accept either{"my_field": "value"} or {"myField": "value"}. Google's standard protobuf Java library works this way.
Currently the ts-proto generated fromJSON only accepts one or the other, as determined by the snakeToCamel option. Ideally snakeToCamel would only affect toJSON (which is how the spec describes it), but fromJSON would accept either one regardless.
The text was updated successfully, but these errors were encountered:
Hi @jdbp-classpass , yep, that is correct. I think we've not implemented this yet because I assume most companies just pick "either snake or camel" are their company's internal standard, and then don't deviate from that.
If you'd like to submit a PR that teaches fromJSON to support either, ideally behind a flag (like another snakeToCamel option I assume), so that current users don't pay for the code size & perf of checking two keys, that would be great! Thanks!
The proto3 JSON specification says that
Proto3 JSON parsers are required to accept both the converted lowerCamelCase name and the proto field name.
. This seems to mean that, given a message with a field like "my_field", thefromJson
method should accept either{"my_field": "value"}
or{"myField": "value"}
. Google's standard protobuf Java library works this way.Currently the ts-proto generated
fromJSON
only accepts one or the other, as determined by thesnakeToCamel
option. IdeallysnakeToCamel
would only affecttoJSON
(which is how the spec describes it), butfromJSON
would accept either one regardless.The text was updated successfully, but these errors were encountered: