C#C
C#4y ago
skyferian

maui deserialize problem

I am having a problem when trying to deserialize api data

C#
  string content = await response.Content.ReadAsStringAsync();
                    Debug.WriteLine("content -->");
                    Debug.WriteLine(content);

                    mylists = JsonSerializer.Deserialize<List<Item>>(content, _jsonSerializerOptions);
                    Debug.WriteLine(mylists);

// this is what content says [{"id":1,"name":"Paprika chips","brand":"Lays","store":"Aldi"},{"id":2,"name":"producttest","brand":"brandttest","store":"Lidl"} so this one is correct but only the deserialize gives me some kind of problem and i do not understand why
this is what mylists says System.Collections.Generic.List`1[Boodschappenlijst.Model.Item]
C#
   public class Item
    {
        public int Id { get; set; }
        public string name { get; set; }
        public string brand { get; set; }
        public string store { get; set; }
    }
Was this page helpful?