Created
April 28, 2014 15:40
-
-
Save imwower/11375774 to your computer and use it in GitHub Desktop.
newtonsoft.json serializer for restsharp
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 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