Skip to content

Commit e296c5a

Browse files
authored
Remove null value exception handling example
Removed example demonstrating exception on explicit null value during deserialization.
1 parent 99a193d commit e296c5a

File tree

1 file changed

+0
-11
lines changed
  • docs/standard/serialization/system-text-json/snippets/nullable-annotations

1 file changed

+0
-11
lines changed

docs/standard/serialization/system-text-json/snippets/nullable-annotations/Nullable.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,6 @@ public static void RunIt()
7373
string jsonMissing = """{}""";
7474
var resultMissing = JsonSerializer.Deserialize<Person>(jsonMissing, options);
7575
Console.WriteLine(resultMissing.Name is null); // True.
76-
77-
// Explicit null value - DOES throw an exception.
78-
string jsonNull = """{"Name":null}""";
79-
try
80-
{
81-
JsonSerializer.Deserialize<Person>(jsonNull, options);
82-
}
83-
catch (JsonException ex)
84-
{
85-
Console.WriteLine(ex.Message); // The constructor parameter 'Name' on type 'Person' doesn't allow null values.
86-
}
8776
}
8877

8978
record Person(string Name);

0 commit comments

Comments
 (0)