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