-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Performance improvements in JsonValue
.
#103733
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
Just confirming that we're not losing the ability to store arbitrary objects in |
We couldn't do that. This change simply isolates that use case from the hot path scenaria. |
src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.IDictionary.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValueOfElement.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValue.CreateOverloads.cs
Show resolved
Hide resolved
/ba-g suppressing unrelated test failure to merge ahead of snap. |
* Performance improvements in JsonValue. * Fix dotnet#103715. * Add more test cases and fix a number of bugs related to DeepEquals and escaping. * Fix number handling corner case.
One of the oddities of
JsonNode
design is that it permits encapsulation of arbitrary .NET objects via theJsonValue
type. This is known to create performance problems since it's not possible to introspectJsonValue
instances without serializing and deserializing the underlying object first. The problem is fairly pervasive since JSON primitives such as boolean, numbers and strings are all represented usingJsonValue
.This PR refactors the implementation of
JsonValue
so that common primitive types and deserialized values backed byJsonElement
are fully segregated from the implementation that admits arbitrary objects. Consequently this change records substantial performance improvements: