Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/Readarr/src/commit/00276041adf50da7bd2ab6b1210fe335e025cad3/NzbDrone.Common/IJsonSerializer.cs You should set ROOT_URL correctly, otherwise the web may not work correctly.
Readarr/NzbDrone.Common/IJsonSerializer.cs

67 lines
2.0 KiB

using System;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace NzbDrone.Common
{
public interface IJsonSerializer
{
T Deserialize<T>(string json) where T : class, new();
string Serialize(object obj);
void Serialize<TModel>(TModel model, Stream outputStream);
object Deserialize(string json, Type type);
}
public class JsonSerializer : IJsonSerializer
{
private readonly Newtonsoft.Json.JsonSerializer _jsonNetSerializer;
public JsonSerializer()
{
var setting = new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
NullValueHandling = NullValueHandling.Ignore,
Formatting = Formatting.Indented,
DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate
};
_jsonNetSerializer = new Newtonsoft.Json.JsonSerializer()
{
DateTimeZoneHandling = setting.DateTimeZoneHandling,
NullValueHandling = setting.NullValueHandling,
Formatting = setting.Formatting,
DefaultValueHandling = setting.DefaultValueHandling,
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
}
public T Deserialize<T>(string json) where T : class, new()
{
return JsonConvert.DeserializeObject<T>(json);
}
public object Deserialize(string json, Type type)
{
return JsonConvert.DeserializeObject(json, type);
}
public string Serialize(object obj)
{
return JsonConvert.SerializeObject(obj);
}
public void Serialize<TModel>(TModel model, Stream outputStream)
{
var jsonTextWriter = new JsonTextWriter(new StreamWriter(outputStream));
_jsonNetSerializer.Serialize(jsonTextWriter, model);
jsonTextWriter.Flush();
}
}
}