[英]Converting YAML to JSON with Python: <block end> found
我正在尝试将以下示例yaml
文件转换为json
test.yaml
- fields: {name: "Test", nr: "000"}
model: testmodel
pk: "1"
然而,打电话
python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin),
sys.stdout, indent=4)' < test.yaml > test.json
返回错误
"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
我的yaml文件出了什么问题?
你的缩进是错的。 你可能意味着:
- fields: {name: "Test", nr: "000"}
model: testmodel
pk: "1"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.