79485879

Date: 2025-03-05 08:50:11
Score: 1
Natty:
Report link

Although .NET has a new static bool DeepEquals(JsonNode, JsonNode) method, it only returns a simple true/false without detailed information about how the two nodes are not equal.

So you can just serialize your JsonDocument to string and use this library LateApexEarlySpeed.Xunit.Assertion.Json to do "json-level" equivalent assertion. As you considered, library will automatically ignore whitespace and other factors inside and give detailed difference message and position.

JsonAssertion.Equivalent("""
    {
      "a": 1,
      "b": 2
    }
    """,
    """
    {
      "b": 2,
      "a": 1
    }
    """);

(I am author of this library)

Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: LateApexEarlySpeed