I am using Unity3D with Boomlagoon JSON from Unity asset store. I am sending a json from server and then extracting a string from that and comparing it with another string in an if statement. I cannot for the death of me make it work.
var reply : String = WebSocketSingleton.getInstance().RecvString();
Debug.Log ("Received: " + reply);
var jsonReply = JSONObject.Parse(reply);
Debug.Log("jsonReply['event']: " + jsonReply["event"].ToString());
Debug.Log("jsonReply['event'] type : " + jsonReply["event"].ToString().GetType());
Debug.Log("login type: " + "login".GetType());
if (jsonReply["event"].ToString() == "login") {
Debug.Log("check");
} else {
Debug.Log("fail");
}
It keeps going to else.
Console log:
Received: {"event":"login","email":"asdf@"}
jsonReply['event']: "login"
jsonReply['event'] type : System.String
login type: System.String
fail
Unity package I am using for json: http://ift.tt/1LAWeH7
I hope I'm not just being a massive idiot...
Aucun commentaire:
Enregistrer un commentaire