Last active
March 19, 2019 11:53
-
-
Save FGtatsuro/0d4e76fe010adce176b8 to your computer and use it in GitHub Desktop.
YAML<->JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# JSON -> YAML(PyYAML==3.11 is required) | |
python -c "import yaml,json; f=open('alpine.json');s=json.load(f);f.close(); f=open('alpine.yaml', 'w');yaml.safe_dump(s, f, default_flow_style=False); f.close()" | |
# YAML -> JSON | |
python -c "import yaml,json; f=open('alpine.yaml');s=yaml.load(f);f.close(); print(json.dumps(s, indent=4))" > alpine2.json | |
# or | |
# (jq is required) | |
python -c "import yaml,json; f=open('alpine.yaml');s=yaml.load(f);f.close(); print(json.dumps(s))"| jq . > alpine2.json | |
# JSONの設定ファイルを受けとるCLIとの連携 | |
python -c "import yaml,json; f=open('alpine.yaml');s=yaml.load(f);f.close(); print(json.dumps(s))" | time packer build - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment