Check if string appears in list of JValues | بلاگ

Check if string appears in list of JValues

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

I have some JSON which I inspect and parse into a JArray. The JSON is similar to this :

"required" : [ "1", "2" ]

Now when it parses, the outcome is an array of JValues. I want to check if my string appears in this list. So, to do this, I do :

JArray requiredArray = JArray.Parse(myJson["required].ToString());

bool exists = requiredArray.Contains("1");

This comes back as false, and I think its due to it comparing a JValue with a string. I try convert the string to a JValue like so :

JValue itemValue = JValue.Parse("1");

It doesn't like that, says cannot convert JToken to JValue.

All I need to know is, does my JArray contain this string value.

asked 48 secs ago
thatOneGuy

...
نویسنده : استخدام کار بازدید : 10 تاريخ : سه شنبه 24 بهمن 1396 ساعت: 22:13