Hi folks,
how do I compare the equality of two JSON objects during runtime without breaking out into the .net world?
I'd like to have something like this:
if MyJsonObject1.Equals(MyJsonObject2) then ...
A workaround could be converting both to text, removing all whitespaces, probably lowercasing everything and then compare the texts. But that will not work if the order of json tokens is different inside the objects:
{ "name": "Adam", "age": "26"} vs. { "age": "26", "name": "Adam"}
Thanks in advance
Markus
Answers
Not sure if I want to implement such a comparer on my own
I do not want to send the two json objects to an external service to have them compared everytime I run my tests. That doesn't make sense.
I found out that the Newtonsoft implementation has something like JToken.DeepEquals (Link) - Sadly this seems not to be available in BC :-(