-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Use System.Text.Json's copy ctor #21016
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
Conversation
Is this something we should patch? |
The copy ctor and the property being tested are new in 5.0. |
I see |
jsonSerializerOptions = new JsonSerializerOptions(jsonSerializerOptions) | ||
{ | ||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, | ||
}; |
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.
Hopefully the new CreateForWeb
option uses the right defaults and then we don't need this at all 👀
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.
@rynowak @pranavkm It seems like you want us to include this in the new JsonSerializerOptions
for web. So, the web options will have PropertyNameCaseInsensitive = true
, PropertyNamingPolicy = JsonNamingPolicy.CamelCase
, and Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
.
Is that correct?
I also pointed this out on dotnet/runtime#34626 (comment) in case you missed it.
cc @layomia
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.
Also cc @terrajobst.
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.
AFAIK, when I spoke to @GrabYourPitchforks, the recommendation was that using UnsafeRelaxedJsonEscaping
is only safe if the JSON wasn't interspersed with markup. Web
might not convey that this is meant for REST \ API scenarios.
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.
Thanks.
No description provided.