Nullable fields in json generated from protobuf file

Null for nil value

my.proto

go mapper

Which will lead to this json response

Omit a field with nil value

If you want to omit the field completely, you can use oneof approach

proto

go mapper

More info on json options for grpc — https://blog.bullgare.com/2020/07/complete-list-of-swagger-options-to-protobuf-file/

Similar Posts

LEAVE A COMMENT