I would like some help to understand this conversion that I am trying to do but it is generating an exception, see:
protected void onPostExecute(String resultado)
{
if(resultado.contains("login_erro"))
{
Toast.makeText(getApplicationContext(), "Login e Senha inválidos", Toast.LENGTH_LONG).show();
}
else
{
try
{
JSONObject json = new JSONObject(resultado);
Usuario user = new Usuario(json.getString("login"), json.getInt("id_funcionario"), json.getInt("prior_usuario"));
Intent abrirPrincipal = new Intent(TelaLogin.this, TelaPrincipal.class);
abrirPrincipal.putExtra("usuario", user);
startActivity(abrirPrincipal);
}
catch (Exception erro)
{
Toast.makeText(getApplicationContext(), erro.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
Exception:
Value br of type java.lang.String cannot be converted to JSONObject
This method receives the output of a post made on a page .php
that is returning a json_encode
with a array
of the resulting table. Can you help me understand?