Handle groups in C# JsonParser

pull/16970/head
Manuel Allenspach 6 months ago
parent 05e5107d98
commit b008e18934
No known key found for this signature in database
GPG Key ID: CF953E6CCFE19AE6
  1. 10
      csharp/src/Google.Protobuf.Test/JsonParserTest.cs
  2. 2
      csharp/src/Google.Protobuf/JsonParser.cs

@ -995,6 +995,16 @@ namespace Google.Protobuf
Assert.AreEqual(0, parsed.FieldName13); Assert.AreEqual(0, parsed.FieldName13);
} }
[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] [Test]
[TestCase("5")] [TestCase("5")]
[TestCase("\"text\"")] [TestCase("\"text\"")]

@ -330,7 +330,7 @@ namespace Google.Protobuf
} }
var fieldType = field.FieldType; var fieldType = field.FieldType;
if (fieldType == FieldType.Message) if (fieldType == FieldType.Message || fieldType == FieldType.Group)
{ {
// Parse wrapper types as their constituent types. // Parse wrapper types as their constituent types.
// TODO: What does this mean for null? // TODO: What does this mean for null?

Loading…
Cancel
Save