mirror of
https://github.com/Radarr/Radarr
synced 2025-01-04 06:23:32 +00:00
Fixed: Serialize flag enum as string also
This commit is contained in:
parent
fcb31ac51b
commit
b0ae4e9a60
2 changed files with 1 additions and 18 deletions
|
@ -21,7 +21,7 @@ public EmbeddedDocumentConverter()
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
};
|
};
|
||||||
|
|
||||||
serializerSettings.Converters.Add(new NoFlagsStringEnumConverter());
|
serializerSettings.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, true));
|
||||||
serializerSettings.Converters.Add(new TimeSpanConverter());
|
serializerSettings.Converters.Add(new TimeSpanConverter());
|
||||||
serializerSettings.Converters.Add(new UtcConverter());
|
serializerSettings.Converters.Add(new UtcConverter());
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Datastore.Converters
|
|
||||||
{
|
|
||||||
public class NoFlagsStringEnumConverter : JsonConverterFactory
|
|
||||||
{
|
|
||||||
private static JsonStringEnumConverter s_stringEnumConverter = new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, false);
|
|
||||||
|
|
||||||
public override bool CanConvert(Type typeToConvert)
|
|
||||||
=> typeToConvert.IsEnum && !typeToConvert.IsDefined(typeof(FlagsAttribute), inherit: false);
|
|
||||||
|
|
||||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
|
|
||||||
=> s_stringEnumConverter.CreateConverter(typeToConvert, options);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue