From 3e99adc41b987cca25a7efb7f7a70d32ab9d6a30 Mon Sep 17 00:00:00 2001 From: Anton Pupkov Date: Mon, 15 Jan 2024 10:16:45 -0800 Subject: [PATCH] Fix Events not parsing correctly --- Dota2GSI/GameState.cs | 2 +- Dota2GSI/Nodes/Events.cs | 2 +- Dota2GSI/Nodes/Node.cs | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Dota2GSI/GameState.cs b/Dota2GSI/GameState.cs index 7f6d77d..c787fca 100644 --- a/Dota2GSI/GameState.cs +++ b/Dota2GSI/GameState.cs @@ -173,7 +173,7 @@ public Events Events { if (events == null) { - events = new Events(GetJObject("events")); + events = new Events(GetJArray("events")); } return events; diff --git a/Dota2GSI/Nodes/Events.cs b/Dota2GSI/Nodes/Events.cs index 6e64d95..05dc642 100644 --- a/Dota2GSI/Nodes/Events.cs +++ b/Dota2GSI/Nodes/Events.cs @@ -17,7 +17,7 @@ public class Events : IEnumerable /// public int Count { get { return _events.Count; } } - internal Events(JObject parsed_data = null) : base() + internal Events(JArray parsed_data = null) : base() { if (parsed_data != null) { diff --git a/Dota2GSI/Nodes/Node.cs b/Dota2GSI/Nodes/Node.cs index d4674eb..07763bc 100644 --- a/Dota2GSI/Nodes/Node.cs +++ b/Dota2GSI/Nodes/Node.cs @@ -53,6 +53,18 @@ internal JObject GetJObject(string property_name) return null; } + internal JArray GetJArray(string property_name) + { + var jtoken = GetJToken(property_name); + + if (jtoken != null) + { + return jtoken as JArray; + } + + return null; + } + internal string GetString(string property_name) {