Created
October 2, 2013 14:26
-
-
Save jahanson/6794595 to your computer and use it in GitHub Desktop.
Helper function to Serialize almost any object to json.
This file contains 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 string ToJSON(this object obj) | |
{ | |
JavaScriptSerializer serializer = new JavaScriptSerializer(); | |
return serializer.Serialize(obj); | |
} | |
public static string ToJSON(this object obj, int recursionDepth) | |
{ | |
JavaScriptSerializer serializer = new JavaScriptSerializer(); | |
serializer.RecursionLimit = recursionDepth; | |
return serializer.Serialize(obj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment