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.
25 lines
833 B
25 lines
833 B
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using Recyclarr.Json;
|
|
|
|
namespace Recyclarr.TrashGuide.ReleaseProfile;
|
|
|
|
public class TermDataConverter : JsonConverter<TermData>
|
|
{
|
|
public override TermData? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
if (reader.TokenType is JsonTokenType.String)
|
|
{
|
|
var str = reader.GetString();
|
|
return str is not null ? new TermData {Term = str} : null;
|
|
}
|
|
|
|
return JsonSerializer.Deserialize<TermData>(ref reader, options.CopyOptionsWithout<TermDataConverter>());
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, TermData value, JsonSerializerOptions options)
|
|
{
|
|
JsonSerializer.Serialize(writer, value, options.CopyOptionsWithout<TermDataConverter>());
|
|
}
|
|
}
|