From 722be68976051658ff814eda12218fefd057899d Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Sat, 3 Feb 2018 12:08:32 +0100 Subject: [PATCH] pass EmitDefaults to jsonpb.Marshaler Signed-off-by: Stephan Renatus --- grpcurl.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grpcurl.go b/grpcurl.go index e691348..acb0fc2 100644 --- a/grpcurl.go +++ b/grpcurl.go @@ -386,7 +386,7 @@ func invokeUnary(ctx context.Context, stub grpcdynamic.Stub, md *desc.MethodDesc var respStr string if stat.Code() == codes.OK { - jsm := jsonpb.Marshaler{Indent: " "} + jsm := jsonpb.Marshaler{EmitDefaults: true, Indent: " "} respStr, err = jsm.MarshalToString(resp) if err != nil { return fmt.Errorf("failed to generate JSON form of response message: %v", err) @@ -449,7 +449,7 @@ func invokeClientStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.Met var respStr string if stat.Code() == codes.OK { - jsm := jsonpb.Marshaler{Indent: " "} + jsm := jsonpb.Marshaler{EmitDefaults: true, Indent: " "} respStr, err = jsm.MarshalToString(resp) if err != nil { return fmt.Errorf("failed to generate JSON form of response message: %v", err) @@ -502,7 +502,7 @@ func invokeServerStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.Met } break } - jsm := jsonpb.Marshaler{Indent: " "} + jsm := jsonpb.Marshaler{EmitDefaults: true, Indent: " "} respStr, err := jsm.MarshalToString(resp) if err != nil { return fmt.Errorf("failed to generate JSON form of response message: %v", err) @@ -588,7 +588,7 @@ func invokeBidi(ctx context.Context, cancel context.CancelFunc, stub grpcdynamic } break } - jsm := jsonpb.Marshaler{Indent: " "} + jsm := jsonpb.Marshaler{EmitDefaults: true, Indent: " "} respStr, err := jsm.MarshalToString(resp) if err != nil { return fmt.Errorf("failed to generate JSON form of response message: %v", err)