Repository navigation
Leave System.Text.Json's own types to its built-in converters [patch] - #101
Merged
Merged
Conversation
JsonNode and JsonDocument have a Parse(string) the factory accepts, so registering it took them over: they were written as a quoted string and object JSON no longer deserialized. IsBuiltInType now excludes every type in System.Text.Json and its sub-namespaces. Fixes #98 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B9RFdjRB3ff72GWre48NPs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B9RFdjRB3ff72GWre48NPs
|
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #98
What changed
JsonNode.Parse(string, …)andJsonDocument.Parse(string, …)return their own types and have only optional extra parameters, soCanConvertaccepted them. Converters inoptions.Converterstake priority over STJ's built-in converters, so registering the factory took these types over: they were written as a quoted string, and object JSON failed with "Expected string token, got StartObject".IsBuiltInTypenow also excludes every type whose namespace isSystem.Text.Jsonor starts withSystem.Text.Json.. That coversJsonNode,JsonObject,JsonArray,JsonValue,JsonDocumentandJsonElement.Tests
New
SystemTextJsonTypeTests:CanConvertis false forJsonNode,JsonObject,JsonArray,JsonValue,JsonDocumentandJsonElementJsonNodeproperty serializes as{"Node":{"a":1}}and deserializes from object JSONJsonDocumentproperty round-trips as an objectWithout the fix, 7 of the new cases fail and 103 other tests pass. With it, all 110 tests pass. The library builds cleanly for all its target frameworks.
This PR is independent of #100 (for #99). Both start from
mainand touch different members.🤖 Generated with Claude Code
https://claude.ai/code/session_01B9RFdjRB3ff72GWre48NPs
Generated by Claude Code