cel-go icon indicating copy to clipboard operation
cel-go copied to clipboard

Support JSON Name in pb field names

Open renevo opened this issue 3 months ago • 1 comments

Feature request checklist

  • [x] There are no issues that match the desired change
  • [ ] The change is large enough it can't be addressed with a simple Pull Request
  • [x] If this is a bug, please file a Bug Report.

Change

Allow for the protobuf field name mapping to use the JSONName instead of the field names.

Example

person.firstName vs. person.first_name

Alternatives considered

I have temporarily forked this repo to support this, it was a pretty simple change, however I am not sure of a good way to make this configurable either through a global var or a build tag for a PR.

https://github.com/google/cel-go/compare/master...Blizzard:cel-go:blizzard

Ideally I don't want to maintain this for for such a small thing. The reason why this is needed in our use case is that we allow for CEL queries to filter data in a graphql API. With the graphql schema being based on the JSON of the data, it is way less confusing to our users than having to do the mental dance of the above example.

renevo avatar Sep 12 '25 22:09 renevo

I have added a PR that uses a global variable to change the behavior, I couldn't come up with a better/cleaner solution to this.

renevo avatar Sep 25 '25 23:09 renevo