MarinKos89
5/22/2019 - 9:14 AM

json To Dynamic

 private static List<dynamic> JsonToDynamic(DevOpsConnector devOps, List<DevOpsFileInformation> fileInformation)
        {
            List<dynamic> configList = new List<dynamic>();

            foreach (var item in fileInformation)
            {
                if (item.name.StartsWith("appsettings"))
                {

                    string wholeFile = devOps.GetFileContent(item);

                    var body = JsonConvert.DeserializeObject<dynamic>(wholeFile);

                    foreach (var element in body)
                    {
                        if (element.Name == "ConnectionStrings")
                        {
                            configList.Add(new { ConnectionString = element.Value });


                        }
                    }

                }
            }
            configList.ForEach(Console.WriteLine);
            return configList;
        }