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
Add JsonNumberHandling.AllowReadingFromString as a JsonSerializer web default #41539
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.
Otherwise; LGTM, thanks.
I assume this was requested by the ASP.NET team (@pranavkm can you verify)? I didn't see this ask in the two linked issues above. Update: per offline discussion, this was recommended during the API review and then discussed again offline with ASP.NET. |
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs
Show resolved
Hide resolved
Moving to 6.0 as the accompanying perf change I'd like to get in along with this PR will not meet the bar for back-porting to the .NET 5 release - #41679. |
Test failures are unrelated: |
Changing such defaults is a breaking change, even if we are making things more forgiving, given these are default settings that folks will rely on, because being strict/validate on its own is a feature. If this leniency is important for Web, we should consider porting the change to 5.0 to avoid having to make a breaking change in the future. |
I believe @layomia is already doing this. |
… default (dotnet#41539) * Add JsonNumberHandling.AllowReadingFromString as a JsonSerializer web default * Add test assertion for number handling option in S.N.H.Json * Test number-as-string behavior in System.Net.Http.Json
Filed a breaking change doc to advertise the significance of this change to ASP.NET Core apps - dotnet/docs#21067. |
The |
@ahsonkhan, check out the doc issue that @layomia linked it explains it pretty well. |
Follow up from #39363 / #30255.
During API review for the number handling feature, it was discussed that number types being written as strings is a common pattern in many JSON producers (e.g API endpoints) across the web. Adding
JsonNumberHandling.AllowReadingFromString
as a web default makes it easier for .NET web applications to consume these numbers in a consistent manner (same options for client/shared/server).