Skip to content

Instantly share code, notes, and snippets.

@dgg
Last active August 26, 2015 13:33
Show Gist options
  • Select an option

  • Save dgg/8e13aea0459b03d57657 to your computer and use it in GitHub Desktop.

Select an option

Save dgg/8e13aea0459b03d57657 to your computer and use it in GitHub Desktop.
compacting-json
Assert.That(someProperJson, new JsonEqualConstraint("{'prop'='value'}"));
var order = new Order
{
// ..
};
var json = order.ToJson();
var expected = "{ 'Customer' : 'John', 'OrderDetails' : # }";
expected = expected.Replace("#", "[{ 'Product' : 'Pen', 'Quantity' : 1 }, { 'Product' : 'Ruler', 'Quantity' : 2 }]");
expected = expected.Replace("'", "\"");
Assert.AreEqual(expected, json);
Assert.That(someProperJson, Must.Be.Json("{'prop'='value'}"));
string json = "{'str' : 'value', 'number': 42}".Jsonify();
var json = new JsonString("{'str' : 'value', 'number': 42}");
// use as a string
string nonCompact = json;
Assert.That(somePropertJson, Is.EqualTo("{'prop'='value'}").AsJson());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment