public void WriteNestedStruct() { JsonSerializerOptions options = new JsonSerializerOptions().SetupExtensions(); const string json = @"{""A"":1,""B"":{""A"":2,""B"":3}}"; FieldSerializationClassWithStruct strct = new FieldSerializationClassWithStruct(); Helper.TestWrite(strct, json, options); }
public void ReadNestedStruct() { const string hexBuffer = "A261410B6142A261410C61420D"; FieldSerializationClassWithStruct strct = Helper.Read <FieldSerializationClassWithStruct>(hexBuffer); Assert.Equal(11, strct.A); Assert.Equal(12, strct.B.A); Assert.Equal(13, strct.B.B); }
public void WriteNestedStruct() { FieldSerializationClassWithStruct strct = new FieldSerializationClassWithStruct(); const string hexBuffer = "A261410B6142A261410C61420D"; Helper.TestWrite(strct, hexBuffer, null, new CborOptions { EnumFormat = ValueFormat.WriteToString }); }
public void ReadNestedStruct() { JsonSerializerOptions options = new JsonSerializerOptions().SetupExtensions(); const string json = @"{""A"":11,""B"":{""A"":12,""B"":13}}"; FieldSerializationClassWithStruct strct = JsonSerializer.Deserialize <FieldSerializationClassWithStruct>(json, options); Assert.Equal(11, strct.A); Assert.Equal(12, strct.B.A); Assert.Equal(13, strct.B.B); }