You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/NzbDrone.Services.Api/Extensions/NancyJsonSerializer.cs

27 lines
777 B

using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nancy;
using Newtonsoft.Json;
namespace NzbDrone.Services.Api.Extensions
{
public class NancyJsonSerializer : ISerializer
{
public readonly static NancyJsonSerializer Instance = new NancyJsonSerializer();
public bool CanSerialize(string contentType)
{
return true;
}
public void Serialize<TModel>(string contentType, TModel model, Stream outputStream)
{
var jsonTextWriter = new JsonTextWriter(new StreamWriter(outputStream));
Serializer.Instance.Serialize(jsonTextWriter, model);
jsonTextWriter.Flush();
}
public IEnumerable<string> Extensions { get; private set; }
}
}