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

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -