diff options
-rw-r--r-- | csharp/src/Google.Protobuf.Test/JsonParserTest.cs | 10 | ||||
-rw-r--r-- | csharp/src/Google.Protobuf/JsonParser.cs | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index ef6d63dbd..3df906257 100644 --- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -996,6 +996,16 @@ namespace Google.Protobuf } [Test] + public void Proto2_Group() + { + string json = "{ \"data\": { \"groupInt32\": 2, \"groupUint32\": 3 } }"; + var parsed = TestAllTypesProto2.Parser.ParseJson(json); + Assert.True(parsed.HasData); + Assert.AreEqual(2, parsed.Data.GroupInt32); + Assert.AreEqual(3, parsed.Data.GroupUint32); + } + + [Test] [TestCase("5")] [TestCase("\"text\"")] [TestCase("[0, 1, 2]")] diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index 1a0da4a39..fcf859dab 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -330,7 +330,7 @@ namespace Google.Protobuf } var fieldType = field.FieldType; - if (fieldType == FieldType.Message) + if (fieldType == FieldType.Message || fieldType == FieldType.Group) { // Parse wrapper types as their constituent types. // TODO: What does this mean for null? |