My problem I have this JSON file:
and I need to save it in the list, but when I try to print the first element of the list, I get a System.ArgumentOutOfRangeException exception, as if my list is empty. this is my code:
JavaScriptSerializer ser = new JavaScriptSerializer(); Causali o = new Causali(); List<CausaliList> lista = new List<CausaliList>(); WebRequest causali = (HttpWebRequest)WebRequest.Create("http://trackrest.cgestmobile.it/causali"); WebResponse risposta = (HttpWebResponse)CreateCausaliRequest(causali).GetResponse(); Stream data = risposta.GetResponseStream(); StreamReader Leggi = new StreamReader(data); string output = Leggi.ReadToEnd(); lista = ser.Deserialize<List<CausaliList>>(output); lst2.Items.Add(lista[0]);
and these are my two classes to save:
class Causali { public int id; public string causaliname; public string identificationcode; public string expired; }
and
class CausaliList { public Causali causali; }
Can you help me solve this problem?
source share