c# - Checking value of JSON property fails to compare to string -


i'm building user registration , store user data in json files. reason can't compare value of property string. sample code:

public bool isregistered() {     jobject data = jobject.parse("{\"registered\":\"yes\"}");     var registered = data["registered"];     if (registered != "yes")     {             return true;     }     return false; } 

i error on if (registered != "yes")

operator of type != cannot used in operand of type jtoken , string

because registered of type jtoken , can not compare string. can cast string this:

var registered = (string)data["registred"]; if (registered != "yes") 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -