Added the SickRage API integration

This commit is contained in:
Jamie 2017-11-24 13:53:51 +00:00
parent 6e04e2effe
commit f21cd89a74
14 changed files with 295 additions and 3 deletions

View file

@ -0,0 +1,27 @@
using Newtonsoft.Json;
namespace Ombi.Helpers
{
public static class JsonConvertHelper
{
public static T[] ParseObjectToArray<T>(object ambiguousObject)
{
var json = ambiguousObject.ToString();
if (string.IsNullOrWhiteSpace(json))
{
return new T[0]; // Could return null here instead.
}
if (json.TrimStart().StartsWith("["))
{
return JsonConvert.DeserializeObject<T[]>(json);
}
if (json.TrimStart().Equals("{}"))
{
return new T[0];
}
return new T[1] { JsonConvert.DeserializeObject<T>(json) };
}
}
}