Jackett/src/Jackett.Common/Utils/JsonContent.cs

21 lines
575 B
C#
Raw Normal View History

2020-02-09 02:35:16 +00:00
using System.Net.Http;
2015-08-02 17:39:32 +00:00
using System.Text;
using Newtonsoft.Json;
2015-08-02 17:39:32 +00:00
namespace Jackett.Common.Utils
2015-08-02 17:39:32 +00:00
{
public class JsonContent : StringContent
{
public JsonContent(object value)
: this(value, Encoding.UTF8)
{
Headers.ContentType.CharSet = "utf-8";
}
public JsonContent(object value, Encoding encoding)
: base(JsonConvert.SerializeObject(value, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }), encoding, "application/json")
{
}
2015-08-02 17:39:32 +00:00
}
}