diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-05-27 13:31:25 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-05-27 13:31:25 +0200 |
commit | 510f349b83a973c754168441deae33c663a267b2 (patch) | |
tree | 2ccad03eb2a55fd0d1955b0c5dbb92d487af8bc3 /utils | |
parent | 6282218f1fc16b41c7bc8fe413dc250c17bed0ad (diff) |
add tool to convert YAML to JSON
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/yaml2json.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/yaml2json.py b/utils/yaml2json.py new file mode 100755 index 0000000..13ff641 --- /dev/null +++ b/utils/yaml2json.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import yaml +import json +import sys + +if __name__ == "__main__": + i = open(sys.argv[1], "r") if sys.argv[1:] else sys.stdin + o = open(sys.argv[2], "w") if sys.argv[2:] else sys.stdout + o.write( json.dumps( yaml.safe_load( i.read() ), indent=4)) + i.close() + o.close() |