Llámenos Ahora (56-43) 2511531

EN TUS MEJORES MOMENTOS

CONTÁCTENOS

Realimentación

Su mensaje se ha salido con exito

live

using System.Net; using System.Web.Script.Serialization; using System.Collections.Generic; string apiUrl = "https://www.mindicador.cl/api"; string jsonString = "{}"; WebClient http = new WebClient(); JavaScriptSerializer jss = new JavaScriptSerializer(); http.Headers.Add(HttpRequestHeader.Accept, "application/json"); jsonString = http.DownloadString(apiUrl); var indicatorsObject = jss.Deserialize<Dictionary<string, object>>(jsonString); Dictionary<string, Dictionary<string, string>> dailyIndicators = new Dictionary<string, Dictionary<string, string>>(); int i = 0; foreach (var key in indicatorsObject.Keys.ToArray()) { var item = indicatorsObject[key]; if (item.GetType().FullName.Contains("System.Collections.Generic.Dictionary")) { Dictionary<string, object> itemObject = (Dictionary<string, object>)item; Dictionary<string, string> indicatorProp = new Dictionary<string, string>(); int j = 0; foreach (var key2 in itemObject.Keys.ToArray()) { indicatorProp.Add(key2, itemObject[key2].ToString()); j++; } dailyIndicators.Add(key, indicatorProp); } i++; } Response.Write("El valor actual de la UF es $" + dailyIndicators["uf"]["valor"]);