{{tag>Brouillon JSON YAML}} # Notes conversion JSON YAML Voir : * https://www.baeldung.com/linux/json-yaml-cli-conversion Voir aussi : * [[Notes ansible-inventory]] * [[ansible_inventory_script_-_inventaire_dynamique_3|Ansible inventaire script - inventaire dynamique vers statique - Conversion JSON YAML INI]] ~~~bash # Source - https://stackoverflow.com/a/60585911 # Posted by Richard Gomes, modified by community. See post 'Timeline' for change history # Retrieved 2026-11-13, License - CC BY-SA 4.0 function yaml_validate { python -c 'import sys, yaml, json; yaml.safe_load(sys.stdin.read())' } function yaml2json { python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read())))' } function yaml2json_pretty { python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read()), indent=2, sort_keys=False))' } function json_validate { python -c 'import sys, yaml, json; json.loads(sys.stdin.read())' } function json2yaml { python -c 'import sys, yaml, json; print(yaml.dump(json.loads(sys.stdin.read())))' } ~~~ FIXME