-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Improve JsonNode.DeepEquals
numeric equality.
#104255
Improve JsonNode.DeepEquals
numeric equality.
#104255
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonElement.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.
Implementation-wise, LGTM. I defer to @tannergooding about appropriateness.
Relates to #97490 |
src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs
Outdated
Show resolved
Hide resolved
…s.cs Co-authored-by: Stephen Toub <stoub@microsoft.com>
JsonNode.DeepEquals
numeric equality.JsonNode.DeepEquals
numeric equality.
src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs
Outdated
Show resolved
Hide resolved
@tannergooding would it be possible to take another look at this? |
The
JsonNode.DeepEquals
implementation currently uses UTF-8 sequence equality when determining if two JSON numbers are equal. This means that under the current semantics1.0
!=1
and-0.0
!=0
.Following feedback from @gregsdennis I put up this PR that attempts to derive numeric equality from
decimal
. This approach has its own share of problems though because we currently have no way of handling numeric values not representable bydecimal
, so it still needs to fallback to sequence equality (aBigDecimal
type might have been useful in this case).Fix #97490.