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.
22 lines
618 B
22 lines
618 B
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Recyclarr.Json;
|
|
|
|
public static class JsonExtensions
|
|
{
|
|
public static JsonSerializerOptions CopyOptionsWithout<T>(this JsonSerializerOptions options)
|
|
where T : JsonConverter
|
|
{
|
|
var jsonSerializerOptions = new JsonSerializerOptions(options);
|
|
|
|
var jsonConverter = jsonSerializerOptions.Converters.FirstOrDefault(x => x.GetType() == typeof(T));
|
|
if (jsonConverter is not null)
|
|
{
|
|
jsonSerializerOptions.Converters.Remove(jsonConverter);
|
|
}
|
|
|
|
return jsonSerializerOptions;
|
|
}
|
|
}
|