encoding/jsonpb: fix unmarshaling of NullValue field
A JSON "null" field should set the NullValue enum field because
NullValue has the custom encoding format of "null".
Change-Id: I2bfa0900de64d7e2874f7c6db04b1cbc0b61b904
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/170107
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/encoding/jsonpb/encode_test.go b/encoding/jsonpb/encode_test.go
index 005de06..96e21f2 100644
--- a/encoding/jsonpb/encode_test.go
+++ b/encoding/jsonpb/encode_test.go
@@ -1177,6 +1177,12 @@
input: &knownpb.Empty{},
want: `{}`,
}, {
+ desc: "NullValue field",
+ input: &pb2.KnownTypes{OptNull: new(knownpb.NullValue)},
+ want: `{
+ "optNull": null
+}`,
+ }, {
desc: "Value empty",
input: &knownpb.Value{},
wantErr: true,