2
I have a function that consumes a REST API and that the sponse me returns a JSON file with a lot of data. But I am error in converting this data to be able to manipulate it in a way but easy.
Here’s a small example of a similar error:
<?php
$json = '{"dados"{"nome":"marcos"}}';
$data = json_encode($json);
$dados = json_decode($data,true);
echo $dados["dados"]["nome"];
?>
Where the mistake is this:
<?php
$json = '{"dados"{"nome":"marcos"}}';
$data = json_encode($json);
$dados = json_decode($data);
echo $dados->dados;
?>
In this the error is similar:
Any tips on how to solve? Similar examples in the stack always show to use the assosiative array with the json_decode($data, true)
but keeps generating the same mistake.
The problem with using json_encode in a return already in JSON. Removing json_encode it worked.
– Marcos Rai Alves da Cunha