Handle groups in C# JsonParser (#16970)

Fixes https://github.com/protocolbuffers/protobuf/issues/16968

Closes #16970

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16970 from CommonGuy:main b008e18934
PiperOrigin-RevId: 638578696
pull/17002/head
Manuel 6 months ago committed by Sandy Zhang
parent 838626d594
commit 0e9dd4ca09
  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);
}
[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\"")]

@ -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?

Loading…
Cancel
Save