У меня есть JSON
вот так:
{
"content": {
"shopCart": {
"numberOfItem": "string",
"shipCostsAmount": "string"
},
"items": {
[
{
"itemQuantity": "1",
"itemAmount": "200",
"itemShelf": "string",
},
"item2": {
"itemQuantity": "1",
"itemAmount": "250",
"itemShelf": "string",
},
"item3": {
"itemQuantity": "1",
"itemAmount": "3000",
"itemShelf": "string",
}
],
}
}
}
Я хочу проверить, что itemShelf
отличается от Liquor
, например, во всех трех пунктах.
Я могу сделать это для одного элемента, как это:
public bool CheckItemShelf(Content content)
{
var itemShelf = content.Items.Item1.itemShelf;
bool result;
if ((itemShelf == "Liquor"))
result = false;
else
result = true;
return result;
}
Как я могу сделать это для трех (или более) элементов?
РЕДАКТИРОВАТЬ:
Вот класс Content:
public class Content {
/// <summary>
/// Gets or Sets ShopCart
/// </summary>
[DataMember(Name="shopCart", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "shopCart")]
public ShopCart ShopCart { get; set; }
/// <summary>
/// Gets or Sets Items
/// </summary>
[DataMember(Name="items", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "items")]
public Items Items { get; set; }
}
EDIT 2:
Я изменил элементы и массив, как я могу проверить, что все значение itemShelf не ликер и есть верный или ложный ответ?