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

protobuf should be un-/marshaled using protojson, not encoding/json #4704

Open
butonic opened this issue May 30, 2024 · 0 comments
Open

protobuf should be un-/marshaled using protojson, not encoding/json #4704

butonic opened this issue May 30, 2024 · 0 comments

Comments

@butonic
Copy link
Contributor

butonic commented May 30, 2024

OMG ... protobuf generated code has a json tag that uses snake_case AND a protobuf tag that uses camel case:

	// REQUIRED.
	// The list of app providers which can open this mime type
	AppProviders []*ProviderInfo `protobuf:"bytes,4,rep,name=app_providers,json=appProviders,proto3" json:"app_providers,omitempty"`

But the json tag and encoding/json should not be used:

Generation of the json tags was a historical mistake. If we could go back in time, we would not have generated it. It gives the illusion that protobuf messages work correctly with encoding/json, but they don't.

Unfortunately, we are using encoding/json all over the place. google.golang.org/protobuf/encoding/protojson should be used.

AFAICT that would change all the generated json clients rely on ... 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant