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