Skip to content

Instantly share code, notes, and snippets.

@PaulSorensen
Created September 26, 2013 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulSorensen/6711996 to your computer and use it in GitHub Desktop.
Save PaulSorensen/6711996 to your computer and use it in GitHub Desktop.
egeek.dk - WCF return JSON, AJAX-enabled WCF Service in less than 3 minutes
public static class JsonHelper
{
public static string ToJson(this object obj)
{
var serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);
}
public static string ToJson(this object obj, int recursionDepth)
{
var 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