Outils pour utilisateurs

Outils du site


all:bibles:linux:commandes:jq

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
all:bibles:linux:commandes:jq [2024/06/14 11:10] – créée - modification externe 127.0.0.1all:bibles:linux:commandes:jq [2024/07/22 11:10] (Version actuelle) – [Validation] omeylhoc
Ligne 1: Ligne 1:
 +====== json ======
  
 +----
 +
 +===== jq =====
 +
 +==== Installation ====
 +
 +=== Package ===
 +
 +<code bash>
 +sudo apt install jq
 +</code>
 +
 +=== Exécutable indépendant ===
 +
 +Télécharger le fichier 64 bits ou 32 bits (à exécuter directement) à partir du site [[https://stedolan.github.io/jq/]]
 +
 +==== Utilisation ====
 +
 +=== Affichage contenu fichier ===
 +
 +<code bash>
 +jq '.' fichier.json
 +</code>
 +
 +=== Accès propriété ===
 +
 +Lecture de la donnée "toto" dans le fichier fichier.json
 +
 +<code bash>
 +jq '.toto' fichier.json
 +</code>
 +
 +Pour accéder au champ titi de la donnée toto :
 +
 +<code bash>
 +jq '.toto.titi' fichier.json
 +</code>
 +
 +=== Accès tableau ===
 +
 +Interrogation de tous les tableaux :
 +
 +<code bash>
 +jq '.[]' fichier.json
 +</code>
 +
 +Interrogation du 2° tableau :
 +
 +<code bash>
 +jq '.[1]' fichier.json
 +</code>
 +
 +Interrogation propriété toto du premier tableau
 +
 +<code bash>
 +jq '.[0].toto' fichier.json
 +</code>
 +
 +Interrogation propriété toto de tous les tableaux :
 +
 +<code bash>
 +jq '.[].toto' fichier.json
 +</code>
 +
 +----
 +
 +===== jo =====
 +
 +[[https://jpmens.net/2016/03/05/a-shell-command-to-create-json-jo/]]
 +
 +----
 +
 +===== JSON Crack =====
 +
 +[[https://jsoncrack.com/editor]]
 +
 +----
 +
 +===== Validation =====
 +
 +[[https://jsonlint.com/|Validation en ligne]]
 +
 +----
 +
 +====== Sources ======
 +
 +[[https://blog.madrzejewski.com/jq-traiter-parser-json-shell-cli/]]\\
 +[[https://unix.stackexchange.com/questions/649526/how-to-edit-a-json-file-using-shell]]
 +
 +----
 +[[all:bibles:linux:commandes:jq|Haut de page]]