How do I check Json array if it contains specific value?
This is code in which I load the data:
dynamic d = JObject.Parse("{number:1000, str:'string', array: [1,2,3,4,5,6]}");
Console.WriteLine(d.number);
Console.WriteLine(d.str);
Console.WriteLine(d.array.Count);
//this does not work
d.array.Contains(1);
You will need to use ToObject to convert the JArray to a list for you to use Contain method.,
d.array.ToObject<List<int>>().Contains(1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With