I'm trying to convert a Json stream from API to a Object, i try also to convert in a List but the result it's the same.
screenshot of the problem https://prnt.sc/po3osq
this is the json [{"time":"1970-01-01T00:00:00.000Z","count":1}]
this the code
public class Mezzo
{
public DateTime time { get; set; }
public int count { get; set; }
}
public class GetBus
{
public List<Mezzo> Bus { get; set; }
}
public String GetListBus()
{
var addr = "http://192.168.43.131:3000/getBus";
var request = (HttpWebRequest)WebRequest.Create(addr);
request.Method = "GET";
var content = string.Empty;
using (var response = (HttpWebResponse)request.GetResponse())
{
using (var stream = response.GetResponseStream())
{
using (var sr = new StreamReader(stream))
{
content = sr.ReadToEnd();
var details = JsonConvert.DeserializeObject<List<GetBus>>(content);
Debug.WriteLine(details);
return "ciao";
}
}
}
}
>(content);` See: [How to auto-generate a C# class file from a JSON string](https://stackoverflow.com/q/21611674/3744182).