Last active
February 17, 2016 22:40
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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