c# - Detect True/False value from a JSON string -


i have following code:

string result = "{\n  \"success\": false,\n  \"error-codes\": [\n    \"missing-input-response\"\n  ]\n}";  var results = jsonconvert.deserializeobject<dynamic>(result);  var r = results.success; 

now need know whether r true or false. here have:

if (r.equals(false)) {     //action } 

but appears above test not working. correct way of finding true or false value in case?

the expression

jsonconvert.deserializeobject<dynamic>(result).success 

actually returns object of type jvalue, not equal false. need coerce return boolean first:

var results = jsonconvert.deserializeobject<dynamic>(result); bool r = results.success; // force "success" boolean. if (!r) {     // action. } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -