using System; using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace PepperDash.Essentials.Core { public static class JsonExtensions { public static List FindTokens(this JToken containerToken, string name) { List matches = new List(); FindTokens(containerToken, name, matches); return matches; } private static void FindTokens(JToken containerToken, string name, List matches) { if (containerToken.Type == JTokenType.Object) { foreach (JProperty child in containerToken.Children()) { if (child.Name == name) { 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); } } } } }