1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00

Implemented GetValues System.Text.Json in message accessor

This commit is contained in:
Jkorf 2024-10-11 16:02:17 +02:00
parent 168dabc11f
commit 79434c7be5

View File

@ -133,7 +133,20 @@ namespace CryptoExchange.Net.Converters.SystemTextJson
}
/// <inheritdoc />
public List<T?>? GetValues<T>(MessagePath path) => throw new NotImplementedException();
public List<T?>? GetValues<T>(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<List<T>>()!;
}
private JsonElement? GetPathNode(MessagePath path)
{