Skip to content

Commit

Permalink
Add System.Text.Json.JsonElement deserializing to TryParseErrors (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
petervandenhout authored Dec 22, 2020
1 parent a94f17f commit 2ab3786
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Opw.HttpExceptions.AspNetCore/ProblemDetailsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public static bool TryParseErrors(this object value, out IDictionary<string, obj
if (value is IDictionary<string, object[]>)
errors = (IDictionary<string, object[]>)value;
#pragma warning restore RCS1220 // Use pattern matching instead of combination of 'is' operator and cast operator.
if (value is JsonElement)
{
var json = ((JsonElement)value).GetRawText();
errors = JsonSerializer.Deserialize<IDictionary<string, object[]>>(json);
}

return errors != null;
}
Expand Down

0 comments on commit 2ab3786

Please sign in to comment.