-
-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem Statement
I would like to compare JsonElement/Json with a detailed error pointing out the difference.
Currently, this code
var json1 = JsonElement.Parse("{ \"abc\": { \"def\" : 1.23 } }");
var json2 = JsonElement.Parse("{ \"abc\": { \"def\": 1.23 } }");
await Assert.That(JsonElement.DeepEquals(json1, json2)).IsTrue(); // OK
await Assert.That(json1).IsEqualTo(json2);fails with
Expected to be equal to { "abc": { "def": 1.23 } }
but found { "abc": { "def" : 1.23 } }
at Assert.That(json1).IsEqualTo(json2)
Proposed Solution
I would like a behavior like this
var json1 = JsonElement.Parse("{ \"abc\": { \"def\" : 1.23 } }");
var json2 = JsonElement.Parse("{ \"abc\": { \"def\": 1.23 } }");
var json3 = JsonElement.Parse("{ \"abc\": { \"def\": 4.56 } }");
await Assert.That(json1).IsEqualTo(json2); // Equivalent -> no throw
await Assert.That(json1).IsEqualTo(json3);
// Throws
// Expected to be equal to { "abc": { "def": 1.23 } }
// but found { "abc": { "def" : 4.56 } }
// Differs at $.abc.defAlternatives Considered
No response
Feature Category
Assertions
How important is this feature to you?
Nice to have - would improve my experience
Additional Context
No response
Contribution
- I'm willing to submit a pull request for this feature
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request