Home > Net > When I do not know if the json contain certain key, how to the fastest to judge the value of this ke
When I do not know if the json contain certain key, how to the fastest to judge the value of this ke
Time:10-07
Can only be judged whether you the first key, any judgment value again, right?
JObject Json=JObject. Parse (text); If (Json. Either ContainsKey (" specific key ") & amp; & Json [r]. "specific" ToString ()=="specific value") //contains a specific "key" and the key has a value of "specific value" meet the conditional The else //does not contain a particular key or contains the key, but the key values are not for "specific value does not meet the conditions of"
is there any way a judgment come out? Such as writing something like this:
if (Json [" specific key]==JValue (" specific value "))//compile by
CodePudding user response:
"Conditions of Null operator " If (Json/" specific "? . ToObject ()=="specific value") { }