From 79434c7be51793a1740741ab5d6dde08a55e57f1 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Fri, 11 Oct 2024 16:02:17 +0200 Subject: [PATCH] Implemented GetValues System.Text.Json in message accessor --- .../SystemTextJsonMessageAccessor.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CryptoExchange.Net/Converters/SystemTextJson/SystemTextJsonMessageAccessor.cs b/CryptoExchange.Net/Converters/SystemTextJson/SystemTextJsonMessageAccessor.cs index 38ff9220..6ec35b0c 100644 --- a/CryptoExchange.Net/Converters/SystemTextJson/SystemTextJsonMessageAccessor.cs +++ b/CryptoExchange.Net/Converters/SystemTextJson/SystemTextJsonMessageAccessor.cs @@ -133,7 +133,20 @@ public CallResult Deserialize(MessagePath? path = null) } /// - public List? GetValues(MessagePath path) => throw new NotImplementedException(); + public List? GetValues(MessagePath path) + { + if (!IsJson) + throw new InvalidOperationException("Can't access json data on non-json message"); + + var value = GetPathNode(path); + if (value == null) + return default; + + if (value.Value.ValueKind != JsonValueKind.Array) + return default; + + return value.Value.Deserialize>()!; + } private JsonElement? GetPathNode(MessagePath path) {