-
Notifications
You must be signed in to change notification settings - Fork 1.6k
protoc-gen-go + omitempty JSON struct tags #799
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
Comments
Same issue! |
Marshaling protobuf messages into JSON requires the use of the I'm curious though in terms of your use case, does the consumer require having those fields? It would be nice if the consumer is more flexible to deal with missing fields. |
Thanks for the reply @cybrcodr ! When I ran into this problem, I was using a protobuf struct as a value in another struct's field (before sending it over to a client via http). I circumvented this issue by making a "client side" struct, that would take the protobuf's struct K/V pairs and translate them into the new struct, doing some data transformations as necessary. It would seem problematic to send over the raw decoded protobuf struct back up to a client via http, since protobuf fields can change and potentially break the client side code. Does this approach seem naive or have glaring issues? I do agree with you that it would be nice if the consumer would be more flexible. |
I'm going to close this in favor of #256. At this point, we're unlikely to allow manual control of the |
proto3
andprotoc-go-gen
generates this message into a struct withjson:...,omitempty
tags on them. Is there a way to prevent,omitempty
tags from being generated on the structs?For the data, it is important that
kill
,deaths
, orassists
, can be 0 -- and I'd like that to appear instead of being empty when I generate JSON from the struct.The text was updated successfully, but these errors were encountered: