Souvent lorsque l’on télécharge un fichier JSON celui-ci s’affiche sur une ligne.
On peut faire un affichage plus sympa à l’aide de python.
Voici ce que l’on trouve dans la documentation python
$ echo '{"json":"obj"}' | python -mjson.tool
{
"json": "obj"
}
$ echo '{ 1.2:3.4}' | python -mjson.tool
Expecting property name: line 1 column 2 (char 2)
On pourra bien sur combiner cette commande avec du wget ou du curl.
$ wget -q -O - http://colas.sebastien.free.fr/projets/infos.json | python3 -m json.tool
{
"site": "http://colas.sebastien.free.fr",
"Author": "Sebastien Colas",
"articles": [
{
"title": "UNIX and Linux Essentials Ed 2",
"url": "http://colas.sebastien.free.fr/index.php/unix-and-linux-essentials-ed-2/"
},
{
"title": "Petit utilitaire en JavaScript",
"url": "http://colas.sebastien.free.fr/index.php/petit-utilitaire-en-javascript/"
}
]
}