Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json_name only supports character strings #496

Closed
hckhilliam opened this issue Jan 31, 2022 · 2 comments
Closed

json_name only supports character strings #496

hckhilliam opened this issue Jan 31, 2022 · 2 comments
Labels
help wanted Extra attention is needed json

Comments

@hckhilliam
Copy link

When compiling a protobuf that has a json_name param, the name must be a valid variable name format, or else it will throw an exception like the following example:

Message

message Foo {
  string bar = 1 [json_name="bar:baz"]
}

Exception

error TS1005: ',' expected.
18692 version: isSet(object.bar:baz)

I assume the fix should instead use object['bar:baz'] instead of the dot notation

@stephenh
Copy link
Owner

@hckhilliam shoot, that's a good point.

I wonder we could have jsonName be conditionally ['foo:bar'] if we detect an invalid symbol, around in here:

https://github.com/stephenh/ts-proto/blob/main/src/main.ts#L1295

Hopefully that would "just work" without too many changes to the rest of that code, and ideally without changing the current output for valid symbols.

I haven't looked at the from json side of things.

If you're interested in working on a PR, that'd be great! Thanks!

@stephenh stephenh added help wanted Extra attention is needed json labels Feb 15, 2022
@stephenh
Copy link
Owner

This is fixed by #520 , thanks @boukeversteegh !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed json
Projects
None yet
Development

No branches or pull requests

2 participants