Skip to content

Instantly share code, notes, and snippets.

@dgg
Created August 26, 2015 13:53
Show Gist options
  • Select an option

  • Save dgg/875ce4bfb0c22943841a to your computer and use it in GitHub Desktop.

Select an option

Save dgg/875ce4bfb0c22943841a to your computer and use it in GitHub Desktop.
compacting-json.inspiration
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment