新建NewtonsoftJsonSerializer.cs
/// <summary>
/// ISerializer implementation based on Newtonsoft.Json.
/// Default serializer used in calls to GetJsonAsync, PostJsonAsync, etc.
/// </summary>
public class NewtonsoftJsonSerializer : IJsonSerializer
{
private readonly JsonSerializerSettings _settings;
/// <summary>
/// Initializes a new instance of the <see cref="NewtonsoftJsonSerializer"/> class.
/// </summary>
/// <param name="settings">Settings to control (de)serialization behavior.</param>
public NewtonsoftJsonSerializer(JsonSerializerSettings settings = null) {
_settings = settings;
}
public string Serialize(object obj, Type type)
{
return JsonConvert.SerializeObject(obj, _settings);
}
public object Deserialize(string json, Type type)
{
return JsonConvert.DeserializeObject(json,type, _settings);
}
}
代码修改为下面的即可