Skip to content

Instantly share code, notes, and snippets.

@absynce
Last active February 17, 2016 22:40
Show Gist options
  • Save absynce/e596bd2a057859ead358 to your computer and use it in GitHub Desktop.
Save absynce/e596bd2a057859ead358 to your computer and use it in GitHub Desktop.
Outputs an object as Json in LINQPad. Adapted from http://stackoverflow.com/a/17602769/448876.
public static class MyExtensions
{
// Adapted from http://stackoverflow.com/a/17602769/448876.
public static String DumpJson<T>(this T obj)
{
return
obj
.ToJson()
.Dump();
}
public static String ToJson<T>(this T obj, Newtonsoft.Json.Formatting formatting = Newtonsoft.Json.Formatting.None)
{
return
Newtonsoft.Json.JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment