-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Unquote primitive string values in JsonNode.ToString() #117993
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
Unquote primitive string values in JsonNode.ToString() #117993
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where JsonNode.ToString() was returning quoted strings for primitive string values created through JsonSerializer.Deserialize, making behavior inconsistent with JsonValue.Create().
Key changes:
- Updated JsonNode.ToString() to handle JsonValueOfJsonString instances by returning unquoted string values
- Made internal JsonValue classes accessible to enable the fix
- Added test coverage for the deserialization scenario
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| JsonNode.To.cs | Added special handling for JsonValueOfJsonString to return unquoted strings in ToString() |
| JsonValueOfJsonPrimitive.cs | Changed access modifiers from private to internal for JsonValue classes and fixed brace alignment |
| ToStringTests.cs | Added test case to verify ToString() behavior for deserialized string nodes |
src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValueOfJsonPrimitive.cs
Show resolved
Hide resolved
|
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonValueOfJsonPrimitive.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.To.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looked like a much bigger change until I turned on 'Hide Whitespace' 😉
|
/ba-g timeouts and unrelated test failure |
|
Noting here that we're not planning to backport this fix to Preview 7 since ASP.NET Core isn't blocked by it and we think the likelihood of it being hit in the wild against Preview 7 is low. |
Fixes #117992