Convert JSON to YAML. Parsing JSON to YAML

前端 未结 6 819
南笙
南笙 2020-12-16 01:18

I\'m working with configuration files so I need to convert JSON to YAML. For example I have this JSON file:

{
  "foo": "bar",
  "baz&         


        
6条回答
  •  时光说笑
    2020-12-16 01:39

    Here's a one liner for a file, suitable for sticking in a bash script. This should work on most default pythons on most systems:

    python -c 'import json; import yaml; print(yaml.dump(json.load(open("inputfile"))))'
    

提交回复
热议问题