Converting YAML to JSON with Python: <block end> found
I am trying to convert the following example yaml
file tojson
test.yaml
- fields: {name: "Test", nr: "000"}
model: testmodel
pk: "1"
However, the challenge
python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin),
sys.stdout, indent=4)' < test.yaml > test.json
returns an error
"expected <block end>, but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block mapping
in "<stdin>", line 1, column 3
expected <block end>, but found '<block mapping start>'
in "<stdin>", line 3, column 5
What's wrong with my yaml file?
+3
source to share