Outils pour utilisateurs

Outils du site


tech:notes_json

Différences

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

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:notes_json [2026/10/22 18:15] – Jean-Baptistetech:notes_json [2026/11/05 21:01] (Version actuelle) – Jean-Baptiste
Ligne 9: Ligne 9:
 | **jq**        | Command-line JSON processor                                                    | | **jq**        | Command-line JSON processor                                                    |
 | **json_pp**   | JSON Pretty Printer                                                            | | **json_pp**   | JSON Pretty Printer                                                            |
-| **JMESPath**  | JMESPath is a query language for JSON (utilisé par `json_query` d'Ansible    | +| **JMESPath**  | JMESPath is a query language for JSON (utilisé par `json_query` d'Ansible      | 
-| **jp**        | The `jp` command is a command line interface to JMESPath                     |+| **jp**        | The `jp` command is a command line interface to JMESPath                       |
  
  
Ligne 79: Ligne 79:
  
 ~~~bash ~~~bash
-cat fic.json |python3 -m json.tool |native2ascii -encoding UTF-8 -reverse+cat fic.json | python3 -m json.tool | native2ascii -encoding UTF-8 -reverse
 ~~~ ~~~
  
Ligne 113: Ligne 113:
 Dico vers JSON ? Dico vers JSON ?
 ~~~bash ~~~bash
-cat plop.t |tr \' \" |sed -e 's/None/""/g' |jq .+cat plop.t | tr \' \" | sed -e 's/None/""/g' | jq .
 ~~~ ~~~
  
Ligne 135: Ligne 135:
 Top level sections Top level sections
 ~~~bash ~~~bash
-cat single-instance.json |jq 'keys[]'+cat single-instance.json | jq 'keys[]'
 ~~~ ~~~
 +
 +jq filtrer les clefs contenant des espaces
 +~~~
 +$ cat Historique.json | jq . | head -3
 +{
 +  "Browser History": [
 +    {
 +~~~
 +
 +~~~bash
 +cat Historique.json | jq '."Browser History"' > Historique2.json
 +~~~
 +
 +
  
 Exemple wildcard Exemple wildcard
Ligne 155: Ligne 169:
  
 ~~~bash ~~~bash
-docker inspect portainer/portainer-ce |jq '.[0].RepoTags'+docker inspect portainer/portainer-ce | jq '.[0].RepoTags'
 ~~~ ~~~
  
 ~~~bash ~~~bash
-ansible -i testsrv, -m setup all |sed -e 's/^.*=>//' |jq -r '.ansible_facts.ansible_mounts[] |.mount'+ansible -i testsrv, -m setup all | sed -e 's/^.*=>//' | jq -r '.ansible_facts.ansible_mounts[] |.mount'
 ~~~ ~~~
  
Ligne 265: Ligne 279:
  
 ~~~bash ~~~bash
-cat inv.yaml |sed -e 's/$/\\n/' -e 's/"/\\"/g' |tr -d '\n'+cat inv.yaml | sed -e 's/$/\\n/' -e 's/"/\\"/g' | tr -d '\n'
 ~~~ ~~~
  
Ligne 295: Ligne 309:
 set -euo pipefail set -euo pipefail
  
-YAML="$(cat inv.yaml |sed -e 's/$/\\n/' -e 's/"/\\"/g' |tr -d '\n')"+YAML="$(cat inv.yaml | sed -e 's/$/\\n/' -e 's/"/\\"/g' | tr -d '\n')"
  
 curl -v -k -u user1:'P@ssw0rd' -H 'Content-Type: application/json' -X POST https://awx.acme.fr/api/v2/job_templates/81/launch/ -d '{ curl -v -k -u user1:'P@ssw0rd' -H 'Content-Type: application/json' -X POST https://awx.acme.fr/api/v2/job_templates/81/launch/ -d '{
Ligne 311: Ligne 325:
  
 ~~~bash ~~~bash
-YAML="$(cat <<'EOF' | sed -e 's/$/\\n/' -e 's/"/\\"/g' |tr -d '\n'+YAML="$(cat <<'EOF' | sed -e 's/$/\\n/' -e 's/"/\\"/g' | tr -d '\n'
 --- ---
 server1: server1:
Ligne 341: Ligne 355:
 JS="$(cat inv.js)" JS="$(cat inv.js)"
  
-JS="$(echo $JS |sed 's/"/\\"/g')"+JS="$(echo $JS | sed 's/"/\\"/g')"
 URL='' URL=''
  
tech/notes_json.1792685701.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki