Visualizzazione risultati 1 fino 4 di 4

Discussione: Errore lettura file json

  1. #1
    piantegrasse non è connesso Neofita
    Data registrazione
    17-03-2011
    Messaggi
    11

    Predefinito 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;
    }
    Ultima modifica di piantegrasse : 30-11-2025 alle ore 01.04.12

  2. #2
    laravista non è connesso Utente AlterBlog
    Data registrazione
    07-12-2019
    Messaggi
    60

    Predefinito

    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

  3. #3
    piantegrasse non è connesso Neofita
    Data registrazione
    17-03-2011
    Messaggi
    11

    Predefinito

    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.

  4. #4
    laravista non è connesso Utente AlterBlog
    Data registrazione
    07-12-2019
    Messaggi
    60

    Predefinito

    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.

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •