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

19 lines
694 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 JsonArray Records => Json.GetArray("records");
public IReadOnlyList<Device> Devices => Json["records"]!
.GetArray("devices")
.NotNull()
.Select(d => new Device(d))
.ToList();
}