-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AsvalGTA
committed
May 3, 2019
1 parent
3d0e15d
commit 8792e47
Showing
16 changed files
with
457 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FModel | ||
{ | ||
public static class JsonExtensions | ||
{ | ||
public static List<JToken> FindTokens(this JToken containerToken, string name) | ||
{ | ||
List<JToken> matches = new List<JToken>(); | ||
FindTokens(containerToken, name, matches); | ||
return matches; | ||
} | ||
|
||
private static void FindTokens(JToken containerToken, string name, List<JToken> matches) | ||
{ | ||
if (containerToken.Type == JTokenType.Object) | ||
{ | ||
foreach (JProperty child in containerToken.Children<JProperty>()) | ||
{ | ||
if (string.Equals(child.Name, name, StringComparison.CurrentCultureIgnoreCase)) | ||
{ | ||
matches.Add(child.Value); | ||
} | ||
FindTokens(child.Value, name, matches); | ||
} | ||
} | ||
else if (containerToken.Type == JTokenType.Array) | ||
{ | ||
foreach (JToken child in containerToken.Children()) | ||
{ | ||
FindTokens(child, name, matches); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.