How is this JSON created? [closed]

-2

I want to create a JSON in php with mysql data only that I do not know how to create the table or the php code so that in the end the json looks like this, I hope your advice, thanks.

[{
"nombre": "Ejemplo",
"url": {
    "small": "imagen1.jpg",
    "medium": "iamgen2.jpg",
    "large": "imagen3.jpg"
},
"fecha": "dd, mm, yy "
},
{
"nombre": "ejemplo",
"url": {
    "small": "imagen4.jpg",
    "medium": "imagen5.jpg",
    "large": "imagen6.jpg"
},
"fecha": "dd, mm, yy"
}]
    
asked by SpaceSpace 31.10.2016 в 21:40
source

1 answer

1

You can use this function to convert your JSON into an array: json_decode()

Anyway, the JSON would look like this if it were an array in PHP:

[
    0 => [
        "nombre" => "Ejemplo",
        "url" => [
            "small" => "imagen1.jpg",
            "medium" => "imagen2.jpg",
            "large" => "imagen3.jpg"
        ],
        "fecha" => "dd, mm, yy"
    ],
    1 => [
        "nombre" => "ejemplo",
        "url" => [
            "small" => "imagen4.jpg",
            "medium" => "imagen5.jpg",
            "large" => "imagen6.jpg"
        ],
        "fecha" => "dd, mm, yy"
    ]
]
    
answered by 31.10.2016 в 21:49