From 09ce5cbedc4d99557b7735f3dfc2d9ed18a892cc Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 19 Jan 2024 03:02:14 +0100 Subject: [PATCH] Fix ID selector when getting shocker ids --- CShocker/CShocker.csproj | 2 +- CShocker/Shockers/APIS/OpenShockHttp.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CShocker/CShocker.csproj b/CShocker/CShocker.csproj index 279caaa..15d853d 100644 --- a/CShocker/CShocker.csproj +++ b/CShocker/CShocker.csproj @@ -7,7 +7,7 @@ Glax https://github.com/C9Glax/CShocker git - 1.2.4 + 1.2.5 diff --git a/CShocker/Shockers/APIS/OpenShockHttp.cs b/CShocker/Shockers/APIS/OpenShockHttp.cs index 38d8497..c755ed6 100644 --- a/CShocker/Shockers/APIS/OpenShockHttp.cs +++ b/CShocker/Shockers/APIS/OpenShockHttp.cs @@ -28,8 +28,7 @@ public class OpenShockHttp : HttpShocker this.Logger?.Log(LogLevel.Debug, $"{requestDevices.RequestUri} response: {responseDevices.StatusCode}\n{deviceJson}"); JObject deviceListJObj = JObject.Parse(deviceJson); List deviceIds = new(); - foreach(JToken device in deviceListJObj.SelectTokens("data")) - deviceIds.Add(device.SelectToken("id")!.Value()!); + deviceIds.AddRange(deviceListJObj["data"]!.Children()["id"].Values()!); List shockerIds = new(); foreach (string deviceId in deviceIds) @@ -49,8 +48,7 @@ public class OpenShockHttp : HttpShocker string shockerJson = shockerStreamReader.ReadToEnd(); this.Logger?.Log(LogLevel.Debug, $"{requestShockers.RequestUri} response: {response.StatusCode}\n{shockerJson}"); JObject shockerListJObj = JObject.Parse(shockerJson); - foreach(JToken shocker in shockerListJObj.SelectTokens("data")) - shockerIds.Add(shocker.SelectToken("id")!.Value()!); + shockerIds.AddRange(shockerListJObj["data"]!.Children()["id"].Values()!); } return shockerIds;