Closed
Description
Hi,
The Marshaler
from jsonpb
does not marshal empty slices, maps and objects even with the EmitDefaults
option.
For example, with following protobuf message:
message Message {
message SubMessage {
string str = 1;
}
repeated string arr = 1;
map<string, string> m = 2;
SubMessage sub = 3;
}
... and the following go code:
func main() {
var (
msg pb.Message
marshaler = jsonpb.Marshaler{
OrigName: true,
EmitDefaults: true,
}
)
if s, err := marshaler.MarshalToString(&msg); err != nil {
log.Fatalf("Could not marshal proto message : %v", err)
} else {
fmt.Println(s)
}
}
I get:
{}
Is that done by design? Or can/will it be fixed?
Metadata
Metadata
Assignees
Labels
No labels