TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shosho s
NA
137
99.3k
Deserializing JSON array into strongly typed .NET object
Mar 10 2019 4:07 PM
When I can call the 3rd party api to get back data i keep getting the error "
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1....."
my json file format is like shown below :
{
"meals": [
{
"idMeal": "52771",
"strMeal": "Spicy Arrabiata Penne",
"strDrinkAlternate": null,
"strCategory": "Vegetarian",
"strArea": "Italian",
"strInstructions": "Bring a large pot of water to a boil. Add kosher salt to the boiling water, then add the pasta. Cook according to the package instructions, about 9 minutes.\r\nIn a large skillet over medium-high heat, add the olive oil and heat until the oil starts to shimmer. Add the garlic and cook, stirring, until fragrant, 1 to 2 minutes. Add the chopped tomatoes, red chile flakes, Italian seasoning and salt and pepper to taste. Bring to a boil and cook for 5 minutes. Remove from the heat and add the chopped basil.\r\nDrain the pasta and add it to the sauce. Garnish with Parmigiano-Reggiano flakes and more basil and serve warm.",
"strMealThumb": "https://www.themealdb.com/images/media/meals/ustsqw1468250014.jpg",
"strTags": "Pasta,Curry",
"strYoutube": "https://www.youtube.com/watch?v=1IszT_guI08",
"strIngredient1": "penne rigate",
"strIngredient2": "olive oil",
"strIngredient3": "garlic",
"strIngredient4": "chopped tomatoes",
"strIngredient5": "red chile flakes",
"strIngredient6": "italian seasoning",
"strIngredient7": "basil",
"strIngredient8": "Parmigiano-Reggiano",
"strIngredient9": "",
"strIngredient10": "",
"strIngredient11": "",
"strIngredient12": "",
"strIngredient13": "",
"strIngredient14": "",
"strIngredient15": "",
"strIngredient16": null,
"strIngredient17": null,
"strIngredient18": null,
"strIngredient19": null,
"strIngredient20": null,
"strMeasure1": "1 pound",
"strMeasure2": "1/4 cup",
"strMeasure3": "3 cloves",
"strMeasure4": "1 tin ",
"strMeasure5": "1/2 teaspoon",
"strMeasure6": "1/2 teaspoon",
"strMeasure7": "6 leaves",
"strMeasure8": "spinkling",
}
]
}
What i have tried is this but im still getting the same error.
var EmpInfo = JsonConvert.DeserializeObject<List<WebApiClass>>(EmpResponse);
I have also tried this, but all the values returned are null :
var test = JsonConvert.DeserializeObject<WebApiClass>(EmpResponse);
Any help is appreciated.
Reply
Answers (
3
)
How to get fields exist on table by passing table name by us
LINQ Query Where Clause when join two tables