In case you want to do it with Linq without a concrete class you could do it this way:
var dictionaryList = (JObject)JsonConvert.DeserializeObject(@"{
""Resources"": [
{
""Key"": ""HeadingCustomerSegments"",
""Value"": ""Customer segments""
},
{
""Key"": ""Clear all"",
""Value"": ""Clear all""
},
{
""Key"": ""Third selection of stores the report will be based on"",
""Value"": ""Third selection of stores the report will be based on""
},
{
""Key"": ""Select the stores to be included in the Dashboard/Opportunity"",
""Value"": ""Select the stores to be included in the Dashboard/Opportunity""
}]
}");
var element = dictionaryList["Resources"]?.FirstOrDefault(x => x["Key"].Value<string>() == "HeadingCustomerSegments");
var value = element != null ? element["Value"]?.Value<string>() : null;
Console.WriteLine(value);
A more proper way, with a concrete class, would be like this:
void Main()
{
var dictionaryList = JsonConvert.DeserializeObject<Response>(@"{
""Resources"": [
{
""Key"": ""HeadingCustomerSegments"",
""Value"": ""Customer segments""
},
{
""Key"": ""Clear all"",
""Value"": ""Clear all""
},
{
""Key"": ""Third selection of stores the report will be based on"",
""Value"": ""Third selection of stores the report will be based on""
},
{
""Key"": ""Select the stores to be included in the Dashboard/Opportunity"",
""Value"": ""Select the stores to be included in the Dashboard/Opportunity""
}]
}");
var value = dictionaryList.Resources.Where(r => r.Key == "HeadingCustomerSegments").Select(r => r.Value).FirstOrDefault();
Console.WriteLine(value);
}
public class Response
{
public List<Resource> Resources { get; set; }
}
public class Resource
{
public string Key { get; set; }
public string Value { get; set; }
}