Innovenergy_trunk/csharp/Lib/Victron/VictronVRM/Reply.cs

20 lines
773 B
C#

using System.Text.Json.Nodes;
using InnovEnergy.Lib.Utils;
namespace InnovEnergy.Lib.Victron.VictronVRM;
public readonly record struct Reply(JsonNode Json)
{
public Boolean Success => Json.TryGetBoolean("success") is not null or true;
public IReadOnlyList<String> Tags => Json.GetArray<String>("tags");
public IReadOnlyList<String> Alarms => Json.GetArray<String>("alarms");
public JsonArray Records => Json.GetArray("records");
public IReadOnlyList<Device> Devices => Json["records"]!
.GetArray("devices")
.NotNull()
.Select(d => new Device(d))
.ToList();
}