Skip to content

Commit

Permalink
Implemented GetValues System.Text.Json in message accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Oct 11, 2024
1 parent 168dabc commit 79434c7
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,20 @@ public CallResult<T> Deserialize<T>(MessagePath? path = null)
}

/// <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)
{
Expand Down

0 comments on commit 79434c7

Please sign in to comment.