shouldBeSameJsonAs

If two strings represent the same JSON regardless of formatting

@trusted
void
shouldBeSameJsonAs
(
in string actual
,
in string expected
,
string file = __FILE__
,
size_t line = __LINE__
)

Examples

// not pure because parseJSON isn't pure
   `{"foo": "bar"}`.shouldBeSameJsonAs(`{"foo": "bar"}`);
   `{"foo":    "bar"}`.shouldBeSameJsonAs(`{"foo":"bar"}`);
   `{"foo":"bar"}`.shouldBeSameJsonAs(`{"foo": "baz"}`).shouldThrow!UnitTestException;
   try
       `oops`.shouldBeSameJsonAs(`oops`);
   catch(Exception e)
       assert(e.msg == "Error parsing JSON: Unexpected character 'o'. (Line 1:1)");

Meta