Outils pour utilisateurs

Outils du site


tech:notes_conversion_json_yaml

Ceci est une ancienne révision du document !


Notes conversion JSON YAML

Voir :

# 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

tech/notes_conversion_json_yaml.1794565059.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki