-
Errore lettura file json
Salve sto cercando di leggere un file json ma esce sempre la pagina bianca senza testo, dove sto sbagliando
file json----------------------
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [16.41, 40.21, 646]
},
"properties": {
"meta": {
"updated_at": "2025-11-29",
"Paese": {
"localita": "Roma",
}
},
---------------------------------
file di lettura php
$url = "filejson.json";
$contents = file_get_contents($url);
$dati = json_decode($contents);
foreach($dati->list as $data) {
echo $update= $dati->properties->meta->updated_at;
}
-
Banalmente provando prima il file JSON su questo sito --> https://jsoneditoronline.org
si vede questo errore in fondo:
Codice:
Quoted object key expected but got '}' at line 13 column 1
-
Il file json che ho scritto è solo uno stralcio dell'intero file, la mia domanda è, dove sbaglio su php che non visualizzo a schermo la riga update.
-
https://www.php.net/manual/en/function.json-decode.php
Codice:
associative
When true, JSON objects will be returned as associative arrays;
when false, JSON objects will be returned as objects.
When null, JSON objects will be returned as associative arrays or objects
depending on whether JSON_OBJECT_AS_ARRAY is set in the flags.