Unquote primitive string values in JsonNode.ToString()#117993
Unquote primitive string values in JsonNode.ToString()#117993PranavSenthilnathan merged 3 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
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
jeffhandley
left a comment
There was a problem hiding this comment.
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