Quick and dirty CLI tool for converting yaml
to json
.
[:~] 1 $ yaml2json <( echo -e '---\nfoo:\n- bar\n- baz' )
{
"foo": [
"bar",
"baz"
]
}
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
import sys, yaml, json | |
import codecs | |
with codecs.open(sys.argv[1], encoding="utf-8") as ifp: | |
json.dump(yaml.load(ifp), codecs.getwriter("utf-8")(sys.stdout), indent=4, ensure_ascii=False) |