Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify what missing members article is about #44400

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/core/whats-new/dotnet-8/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Required modifier for first parameter: System.Runtime.InteropServices.InAttribut

### Serialization

Many improvements have been made to <xref:System.Text.Json?displayProperty=fullName> serialization and deserialization functionality in .NET 8. For example, you can [customize handling of members that aren't in the JSON payload](../../../standard/serialization/system-text-json/missing-members.md).
Many improvements have been made to <xref:System.Text.Json?displayProperty=fullName> serialization and deserialization functionality in .NET 8. For example, you can [customize handling of JSON properties that aren't in the POCO](../../../standard/serialization/system-text-json/missing-members.md).

The following sections describe other serialization improvements:

Expand Down
2 changes: 1 addition & 1 deletion docs/fundamentals/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ items:
href: ../standard/serialization/system-text-json/nullable-annotations.md
- name: Allow invalid JSON
href: ../standard/serialization/system-text-json/invalid-json.md
- name: Handle missing members
- name: Handle unmapped members
href: ../standard/serialization/system-text-json/missing-members.md
- name: Handle overflow JSON, use JsonElement or JsonNode
href: ../standard/serialization/system-text-json/handle-overflow.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: Handle missing members during deserialization
title: Handle unmapped members during deserialization
description: "Learn how to configure the JSON deserialization behavior when properties are present in the JSON payload that aren't present in the POCO type."
ms.date: 03/01/2023
ms.date: 01/15/2025
no-loc: [System.Text.Json]
dev_langs:
- "csharp"
---

# Handle missing members during deserialization
# Handle unmapped members during deserialization

By default, if the JSON payload you're deserializing contains properties that don't exist in the deserialized plain old CLR object (POCO) type, they're simply ignored. Starting in .NET 8, you can specify that all members must be present in the payload. If they're not, a <xref:System.Text.Json.JsonException> exception is thrown. You can configure this behavior in one of three ways:
By default, if the JSON payload you're deserializing contains properties that don't exist in the plain old CLR object (POCO) type, they're simply ignored. Starting in .NET 8, you can specify that *all payload properties must exist in the POCO*. If they're not, a <xref:System.Text.Json.JsonException> exception is thrown during deserialization. You can configure this behavior in one of three ways:

- Annotate your POCO type with the <xref:System.Text.Json.Serialization.JsonUnmappedMemberHandlingAttribute> attribute, specifying either to <xref:System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip> or <xref:System.Text.Json.Serialization.JsonUnmappedMemberHandling.Disallow> missing members.
- Annotate your POCO type with the <xref:System.Text.Json.Serialization.JsonUnmappedMemberHandlingAttribute> attribute, specifying either to <xref:System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip> or <xref:System.Text.Json.Serialization.JsonUnmappedMemberHandling.Disallow> unmapped members.

```csharp
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
Expand Down
Loading