shouldBeSameJsonAs

If two strings represent the same JSON regardless of formatting

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

Examples

1 // not pure because parseJSON isn't pure
2    import unit_threaded.asserts;
3    `{"foo": "bar"}`.shouldBeSameJsonAs(`{"foo": "bar"}`);
4    `{"foo":    "bar"}`.shouldBeSameJsonAs(`{"foo":"bar"}`);
5    `{"foo":"bar"}`.shouldBeSameJsonAs(`{"foo": "baz"}`).shouldThrow!UnitTestException;
6    try
7        `oops`.shouldBeSameJsonAs(`oops`);
8    catch(Exception e)
9        assertEqual(e.msg, "Error parsing JSON: Unexpected character 'o'. (Line 1:1)");

Meta