Skip to content

Commit c4b519c

Browse files
Clarify that missing properties are left at default values, not set to null
Co-authored-by: eiriktsarpalis <[email protected]>
1 parent e296c5a commit c4b519c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/standard/serialization/system-text-json/nullable-annotations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ It's important to understand the distinction between *missing JSON properties* a
9292
During deserialization, when `RespectNullableAnnotations` is `true`:
9393

9494
- An **explicit null value** throws an exception for non-nullable properties. For example, `{"Name":null}` throws an exception when deserializing to a non-nullable `string Name` property.
95-
- A **missing property** doesn't throw an exception, even for non-nullable properties. For example, `{}` doesn't throw an exception when deserializing to a non-nullable `string Name` property. The property is set to `null`.
95+
- A **missing property** doesn't throw an exception, even for non-nullable properties. For example, `{}` doesn't throw an exception when deserializing to a non-nullable `string Name` property. The serializer doesn't set the property, leaving it at its default value from the constructor. For an uninitialized non-nullable reference type, this results in `null`, which triggers a compiler warning.
9696

9797
The following code shows how a missing property does NOT throw an exception during deserialization:
9898

0 commit comments

Comments
 (0)