0
this.token()
is a String
of the kind {"erro" : "Valor do erro"}
.
But also, in case of success it may be: {"token" : "Valor do token"}
My goal with the code below is to find out if the first index of this JSONObject
to be created will "erro"
or "token"
and I’m trying that way, but it looks like you’re testing whether the value for the index "erro"
is null and not whether the error index itself exists or not.
JSONObject token = new JSONObject(this.token());
if (token.get("erro").equals(null))
this.resposta.setText(token.getString("token"));
else
this.resposta.setText(token.getString("erro"));
That’s right! Thank you very, very much!
– Carlos Rocha