<PackageReference Include="System.Text.Json" Version="6.0.11" />

LargeJsonObjectExtensionDataSerializationState

Implements a mitigation for deserializing large JsonObject extension data properties. Extension data properties use replace semantics when duplicate keys are encountered, which is an O(n) operation for JsonObject resulting in O(n^2) total deserialization time. This class mitigates the performance issue by storing the deserialized properties in a temporary dictionary (which has O(1) updates) and copies them to the destination object at the end of deserialization.
public const int LargeObjectThreshold = 25

public JsonObject Destination { get; }

public void AddProperty(string key, JsonNode value)

Stores a deserialized property to the temporary dictionary, using replace semantics.

public void Complete()

Copies the properties from the temporary dictionary to the destination JsonObject.