Skip to content

Conversation

@PranavSenthilnathan
Copy link
Member

Fixes #117992

@PranavSenthilnathan PranavSenthilnathan added this to the 10.0.0 milestone Jul 23, 2025
@PranavSenthilnathan PranavSenthilnathan self-assigned this Jul 23, 2025
Copilot AI review requested due to automatic review settings July 23, 2025 19:49
Copy link
Contributor

Copilot AI left a 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

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

@PranavSenthilnathan PranavSenthilnathan enabled auto-merge (squash) July 24, 2025 14:14
Copy link
Member

@jeffhandley jeffhandley left a 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' 😉

@PranavSenthilnathan
Copy link
Member Author

/ba-g timeouts and unrelated test failure

@PranavSenthilnathan PranavSenthilnathan merged commit 9e82819 into dotnet:main Jul 24, 2025
81 of 87 checks passed
@jeffhandley
Copy link
Member

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.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToString for JsonValue is not special cased correctly

3 participants