We use a combination of protobuf and json in our platform. The current protobuf implementation will add "omitempty" tags to all json fields. This can be problematic as go base values will not show up in the json.
For example:
message Response {
bool success = 1;
int64 count = 2;
}
if success == false and count == 0, they will not show up in the json even though those are perfectly valid values.
I'm not sure what he solution is here but it would be nice to have an option to not omitempty.
The officially support mechanism for rendering protos as JSON is to use the included jsonpb package.
@dsymonds Could u describle it more clearly? How to solve the problem?
@skadilover use jsonpb package with EmitDefault set to true, found here: https://godoc.org/github.com/golang/protobuf/jsonpb#Marshaler
Most helpful comment
@skadilover use jsonpb package with EmitDefault set to true, found here: https://godoc.org/github.com/golang/protobuf/jsonpb#Marshaler