Example #1
0
            static void Main(string[] args)
            {
                InfoCollector collector = new InfoCollector();

                collector.ClientSetup();

                HttpResponseMessage response = collector.GetResponseFromRequest("stock/clf/chart/5y").Result;

                String JsonString = collector.GetStringFromResponse(response).Result;

                JArray jsonObjectArray = JArray.Parse(JsonString);

                //https://stackoverflow.com/questions/15726197/parsing-a-json-array-using-json-net
                foreach (JObject jsonObject in jsonObjectArray.Children <JObject>())
                {
                    foreach (JProperty jsonProperty in jsonObject.Properties())
                    {
                        String name  = jsonProperty.Name;
                        String value = (String)jsonProperty.Value;
                    }
                }

                ////https://stackoverflow.com/questions/12676746/parse-json-string-in-c-sharp
                //foreach (JObject jsonObject in jsonObjectArray)
                //{
                //    foreach (KeyValuePair<String, JToken> obj in jsonObject)
                //    {
                //        //var Key = obj.Key;
                //        var close = (String)obj.Value["close"];
                //    }
                //}

                //List<StockInfo> si = JsonConvert.DeserializeObject<List<StockInfo>>(JsonString);

                IEnumerable <StockInfo> si2 = JsonConvert.DeserializeObject <IEnumerable <StockInfo> >(JsonString).Reverse();
            }