22 lines
668 B
C#
22 lines
668 B
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace JSMR.Infrastructure.Integrations.DLSite.Serialization;
|
|
|
|
public sealed class ProductInfoOptionsConverter : JsonConverter<string[]>
|
|
{
|
|
public override string[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
string value = reader.GetString() ?? string.Empty;
|
|
|
|
if (string.IsNullOrEmpty(value))
|
|
return [];
|
|
|
|
return [.. value.Split('#')];
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, string[] value, JsonSerializerOptions options)
|
|
{
|
|
writer.WriteStringValue(string.Join("#", value));
|
|
}
|
|
} |