// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Linq; using System.Collections.Generic; using System.Web.Script.Serialization; namespace E { public class Entry { public string symbol { get; set; } public string name { get; set; } public string exch { get; set; } public string type { get; set; } public string exchDisp { get; set; } } public class ResultSetData { public string Query { get; set; } public List Result { get; set; } } public class Data { public ResultSetData ResultSet { get; set; } } public class Program { public static void Main(string[] args) { string s = "{\"ResultSet\":{\"Query\":\"ya\",\"Result\": [{\"symbol\":\"YHOO\",\"name\": \"Yahoo! Inc.\",\"exch\": \"NMS\", \"type\": \"S\",\"exchDisp\":\"NASDAQ\"},{\"symbol\":\"AUY\",\"name\": \"Yamana Gold, Inc.\",\"exch\": \"NYQ\",\"type\": \"S\",\"exchDisp\": \"NYSE\"},{\"symbol\":\"YZC\",\"name\": \"Yanzhou Coal Mining Co. Ltd. \",\"exch\": \"NYQ\",\"type\": \"S\",\"exchDisp\":\"NYSE\"},{\"symbol \":\"YRI.TO\",\"name\": \"YAMANA GOLD INC COM NPV\",\"exch\": \"TOR\", \"type\": \"S\",\"exchDisp\":\"Toronto\"},{\"symbol\":\"8046.TW\", \"name\": \"NAN YA PRINTED CIR TWD10\",\"exch\": \"TAI\",\"type\": \"S \",\"exchDisp\":\"Taiwan\"},{\"symbol\":\"600319.SS\",\"name\": \"WEIFANG YAXING CHE 'A'CNY1\",\"exch\": \"SHH\",\"type\": \"S\", \"exchDisp\":\"Shanghai\"},{\"symbol\":\"1991.HK\",\"name\": \"TA YANG GROUP\",\"exch\": \"HKG\",\"type\": \"S\",\"exchDisp\":\"Hong Kong\"}, {\"symbol\":\"1303.TW\",\"name\": \"NAN YA PLASTIC TWD10\",\"exch\": \"TAI\",\"type\": \"S\",\"exchDisp\":\"Taiwan\"},{\"symbol\":\"0294.HK \",\"name\": \"YANGTZEKIANG\",\"exch\": \"HKG\",\"type\": \"S\", \"exchDisp\":\"Hong Kong\"},{\"symbol\":\"YAVY\",\"name\": \"Yadkin Valley Financial Corp.\",\"exch\": \"NMS\",\"type\": \"S\",\"exchDisp \":\"NASDAQ\"}]}}"; Console.WriteLine(s); JavaScriptSerializer jss = new JavaScriptSerializer(); Data d = jss.Deserialize(s); foreach(var sym in d.ResultSet.Result.Where(r => r.exch == "HKG")) { Console.WriteLine(sym.name + " @ " + sym.exchDisp); } } } }