Skip to content

Commit ab8c52e

Browse files
author
arkadiuszbiel
committed
fix for situation when is null value or is not JObject
1 parent 5a3b692 commit ab8c52e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,4 @@ src/Skybrud.Essentials/Skybrud.Essentials.csproj.DotSettings
111111
releases/nuget/Skybrud.Essentials.*/
112112
releases/github/Skybrud.Essentials.*/
113113
src/.vs/
114+
src/.idea/

src/Skybrud.Essentials/Json/Extensions/JObjectExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,9 @@ public static T[] GetArray<T>(this JObject obj, string path, Func<JObject, T> ca
466466
if (!(obj?.SelectToken(path) is JArray token)) return null;
467467

468468
return (
469-
from JObject child in token
470-
select callback(child)
469+
from child in token
470+
where child is JObject
471+
select callback((JObject)child)
471472
).ToArray();
472473

473474
}

0 commit comments

Comments
 (0)