2021-08-27 15:03:47 +00:00
|
|
|
using System;
|
2020-12-22 12:15:26 +00:00
|
|
|
using System.Text.Json;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
namespace Myriad.Serialization
|
|
|
|
{
|
|
|
|
public class JsonStringConverter: JsonConverter<object>
|
|
|
|
{
|
|
|
|
public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
|
|
{
|
|
|
|
var str = JsonSerializer.Deserialize<string>(ref reader);
|
|
|
|
var inner = JsonSerializer.Deserialize(str!, typeToConvert, options);
|
|
|
|
return inner;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options)
|
|
|
|
{
|
|
|
|
var inner = JsonSerializer.Serialize(value, options);
|
|
|
|
writer.WriteStringValue(inner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|