C#C
C#4y ago
Luciferno

Deserialization Error

So I make a call to my API and this is what i get in return :
[
   {
      "menuId":1,
      "menuName":"Voorgerechten",
      "menuPrice":15.00,
      "dishes":[
         {
            "dishId":1,
            "dishName":"Broodje Kaas",
            "dishPrice":5.00,
            "dishType":"Voorgerecht"
         },
         {
            "dishId":2,
            "dishName":"Broodje Ham",
            "dishPrice":5.00,
            "dishType":"Voorgerecht"
         },
         {
            "dishId":3,
            "dishName":"Broodje Worst",
            "dishPrice":5.00,
            "dishType":"Voorgerecht"
         }
      ]
   }
]

And I try to Desiralize in to this mode :
    public class Menu
    {
        public int MenuId { get; set; }

        public string MenuName { get; set; }

        public decimal MenuPrice { get; set; }

        public List<Dish> Dishes { get; set; } = new();
    }

As you can see on my photo the deserializedMenu contains element but it does not have the correct values and I don'nt know why
unknown.png
Was this page helpful?