1
am having a problem getting data from a json file! Good initially I get Json via CURL POST and I make the Decode with true so it becomes an array:
$data = json_decode(file_get_contents('php://input'));
return (array) $data;
break;
Later I try to find the information that is in the following structure:
{
"acesso":
{
"acessoUsuario":"usuario",
"acessoSenha":"senha"
}
}
When returning the data already in array I run $data['access'] and get the following view:
{
"acessoUsuario":"topsat",
"acessoSenha":"4501"
}
However when trying the values from within with $date['access']['login'] I get the following return:
Fatal error: Uncaught Error: Cannot use object of type stdClass as array in
Exactly on the line where the $data['access']['access'], this only occurs when I try to access the information more inside than just the first level of the array.
Does anyone know any way I can access this information directly?
You say "and I do Code with true", but you don’t call
json_decode
with thetrue
in the second parameter. Please check?– Woss
Opa friend, really by a disconnected ended up without the True and for me it was all right! kk Thanks for noticing this, now it’s working!
– Otavio Fausto