I have a list like
{
"Nutrients": [{
"vitamin": "vitamin C",
"potassium": "195mg",
"sodium": "2mg",
"cholesterol": "",
"display_name": "Apple"
}, {
"vitamin": "vitamin B",
"potassium": "176mg",
"sodium": "2mg",
"cholesterol": "",
"display_name": "Grape"
}],
"General_name": "Fruits",
"country_of_origin": "France"
}
{
"Nutrients": [{
"vitamin": "vitamin B",
"potassium": "196mg",
"sodium": "115mg",
"cholesterol": "123mg",
"display_name": "Chicken"
}, {
"vitamin": "vitamin B",
"potassium": "360mg",
"sodium": "53mg",
"cholesterol": "68mg",
"display_name": "Chicken"
}],
"General_name": "Meat",
"country_of_origin": "Denmark"
}
我需要找出那些胆固醇为空字符串的项目的通用名称。
我尝试使用LINQ Lambda表达式:
var elements=items.SelectMany(c =>c.Nutrients)
.Where(a => !string.IsNullOrEmpty(a.cholesterol))
.ToList();
我的问题是如何从这个条件中获取通用名称