17 lines
491 B
C#
17 lines
491 B
C#
|
using System.Text.Json;
|
||
|
using System.Text.Json.Serialization;
|
||
|
|
||
|
namespace InnovEnergy.Lib.Units.Json;
|
||
|
|
||
|
public class CurrentConverter : JsonConverter<Current>
|
||
|
{
|
||
|
public override Current Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||
|
{
|
||
|
return new Current(reader.GetDecimal());
|
||
|
}
|
||
|
|
||
|
public override void Write(Utf8JsonWriter writer, Current value, JsonSerializerOptions options)
|
||
|
{
|
||
|
writer.WriteNumberValue(value.Value);
|
||
|
}
|
||
|
}
|