using System.IO; using System.Linq; using Nancy; using Nancy.Responses; using Newtonsoft.Json; namespace NzbDrone.Api.Extentions { public static class JsonExtensions { public static T FromJson(this Stream body) { var reader = new StreamReader(body, true); body.Position = 0; var value = reader.ReadToEnd(); return JsonConvert.DeserializeObject(value, Serializer.Settings); } public static JsonResponse AsResponse(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK) { var jsonResponse = new JsonResponse(model, new NancyJsonSerializer()) { StatusCode = statusCode }; return jsonResponse; } } }