Skip to content

Instantly share code, notes, and snippets.

@imwower
Created April 28, 2014 15: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 imwower/11375774 to your computer and use it in GitHub Desktop.
Save imwower/11375774 to your computer and use it in GitHub Desktop.
newtonsoft.json serializer for restsharp
public class RestSharpJsonSerializer : ISerializer
{
private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
};
public RestSharpJsonSerializer()
{
ContentType = "application/json;charset=utf-8";
}
#region ISerializer memebers
public string ContentType { get; set; }
public string DateFormat { get; set; }
public string Namespace { get; set; }
public string RootElement { get; set; }
public string Serialize(object obj)
{
return JsonConvert.SerializeObject(obj, jsonSettings);
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment