mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
json response from API are now in pascalCasing
This commit is contained in:
parent
e720094f9c
commit
9969f66201
11 changed files with 75 additions and 11 deletions
25
NzbDrone.Api/Extentions/RequestExtensions.cs
Normal file
25
NzbDrone.Api/Extentions/RequestExtensions.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
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<T>(this Stream body)
|
||||
{
|
||||
var reader = new StreamReader(body, true);
|
||||
body.Position = 0;
|
||||
var value = reader.ReadToEnd();
|
||||
return JsonConvert.DeserializeObject<T>(value, Serializer.Settings);
|
||||
}
|
||||
|
||||
public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
var jsonResponse = new JsonResponse<TModel>(model, new NancyJsonSerializer()) { StatusCode = statusCode };
|
||||
return jsonResponse;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue