I feel like I'm taking crazy pills here... but how can I compare two JsonDocument
s (or JsonElement
s or what have you) for JSON equality, i.e. same keys with same values?
To limit the scope, the ability to perform this comparison in a unit test is sufficient unto the day.
I have a unit test in which I want to compare the result of a function that returns a JsonDocument
to some expected value. Things that don't work include using FluentAssertions.Json (because my type is not JObject
), and comparing the value of GetRawText
because I don't care about the whitespace.
I guess I could write the strings out and re-serialize them or something but this honestly feels like such a hack that I must be doing something wrong.
I understand the business logic of comparing them, I have seen the other questions like this and this. The first is much more in keeping with what I want, it's just an embarrassing result for C#... The second is not what I need at all.