I'm having a problem getting values from a JSON object.
The script is working normally using another JSON structure, however with this specific JSON file, the error is happening.
I believe the error is in "" content ": ["
at the beginning of JSON.
I am using the following script:
<?php
$json_strdoc = file_get_contents("http://app.tce.ma.gov.br:8889/contratos/documentos?numeroContrato=03.004.0410");
$objdoc = json_decode($json_strdoc);
echo "
<table class='table tabela-nova'>
<thead>
<tr>
<th scope='col' style='width: 28%;'>Tipo de Documento</th>
<th scope='col' style='width: 35.5%;'>Descrição</th>
<th scope='col'>Data de Envio</th>
<th scope='col'>Baixar</th>
</tr>
</thead>
<tbody>";
foreach ($objdoc as $itemdoc){
echo "
<tr>
<td>".$itemdoc->content->documentos->tipoDocumento->nome."</td>
<td>".$itemdoc->content->documentos->assunto."</td>
<td>".$itemdoc->content->documentos->dataEnvio."</td>
<td><span class='baixar'><i class='fa fa-angle-down'></i></span><a class='link-baixar' target='_blank' href='$itemdoc->content->link'> Baixar arquivo </a></td>
</tr>
" ;
}
echo "
</tbody>
</table>";
?>
However, the error is returning:
Notice: Trying to get property of non-object in...
The result should look like this: