You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the version 1.6.0 it is possible to use a [raw string literal](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string)
120
+
with a JSON content in the string:
121
+
122
+
```csharp
123
+
[Fact]
124
+
publicvoidSerialization()
125
+
{
126
+
varcustomer=newCustomer()
127
+
{
128
+
Id=1234,
129
+
Name="Gilles TOURREAU",
130
+
Gender=Gender.Male,
131
+
};
132
+
133
+
customer.Should().BeJsonSerializableInto(
134
+
"""
135
+
{
136
+
"id": 1234,
137
+
"name": "Gilles TOURREAU",
138
+
"gender": 100
139
+
}
140
+
""");
141
+
}
142
+
```
143
+
119
144
### Test the deserialization of a JSON object to a .NET Object
120
145
You can in the same way test the deserialization JSON object into a .NET object.
121
146
@@ -139,7 +164,32 @@ public void Deserialization()
139
164
}
140
165
```
141
166
142
-
## Test polymorphisme serialization with property discriminator
167
+
Since the version 1.6.0 it is possible to use a [raw string literal](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string)
168
+
with a JSON string content as input of the `Should()` to assert:
## Test polymorphism serialization with property discriminator
143
193
With the .NET 7.0 version of the `System.Text.Json` it is possible to serialize and deserialize JSON object
144
194
with property discriminators for polymorphism scenario
145
195
(See the [How to serialize properties of derived classes with System.Text.Json](https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism?pivots=dotnet-7-0))
0 commit comments