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/decode_test.go b/encoding/jsonpb/decode_test.go
index 1e9bd98..e7f4239 100644
--- a/encoding/jsonpb/decode_test.go
+++ b/encoding/jsonpb/decode_test.go
@@ -439,24 +439,31 @@
 		desc:         "enum set to number string",
 		inputMessage: &pb3.Enums{},
 		inputText: `{
-  "sEnum": "1",
+  "sEnum": "1"
 }`,
 		wantErr: true,
 	}, {
 		desc:         "enum set to invalid named",
 		inputMessage: &pb3.Enums{},
 		inputText: `{
-  "sEnum": "UNNAMED",
+  "sEnum": "UNNAMED"
 }`,
 		wantErr: true,
 	}, {
 		desc:         "enum set to not enum",
 		inputMessage: &pb3.Enums{},
 		inputText: `{
-  "sEnum": true,
+  "sEnum": true
 }`,
 		wantErr: true,
 	}, {
+		desc:         "enum set to JSON null",
+		inputMessage: &pb3.Enums{},
+		inputText: `{
+  "sEnum": null
+}`,
+		wantMessage: &pb3.Enums{},
+	}, {
 		desc:         "proto name",
 		inputMessage: &pb3.JSONNames{},
 		inputText: `{
@@ -1478,6 +1485,20 @@
 		},
 		wantErr: true,
 	}, {
+		desc:         "NullValue field with JSON null",
+		inputMessage: &pb2.KnownTypes{},
+		inputText: `{
+  "optNull": null
+}`,
+		wantMessage: &pb2.KnownTypes{OptNull: new(knownpb.NullValue)},
+	}, {
+		desc:         "NullValue field with string",
+		inputMessage: &pb2.KnownTypes{},
+		inputText: `{
+  "optNull": "NULL_VALUE"
+}`,
+		wantMessage: &pb2.KnownTypes{OptNull: new(knownpb.NullValue)},
+	}, {
 		desc:         "BytesValue",
 		inputMessage: &knownpb.BytesValue{},
 		inputText:    `"aGVsbG8="`,