C
C#•3y 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"
}
]
}
]
[
{
"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();
}
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
5 Replies
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Luciferno
LucifernoOP•3y ago
I tried that did not work.
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Luciferno
LucifernoOP•3y ago
Ey the options worked! thanks 😄
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server