PROPERTY
JsonDocumentOptions.AllowDuplicateProperties
In .NET 10, set false when parsing a JSON document to reject duplicate object property names. This is a DOM parsing option, separate from JsonSerializerOptions.
Formal Syntax & Structure
csharp syntaxcsharp
new JsonDocumentOptions { AllowDuplicateProperties = false }Working Example
Example Snippetcsharp
using System;using System.IO;using System.Collections.Generic;using System.Text.Json;try { using var d = JsonDocument.Parse("{\"a\":1,\"a\":2}",new JsonDocumentOptions { AllowDuplicateProperties = false }); } catch(JsonException) { Console.WriteLine("Rejected"); }