我尝试将以下示例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文件出了什么问题?
答案 0 :(得分:3)
你的缩进是错误的。你可能意味着:
- fields: {name: "Test", nr: "000"}
model: testmodel
pk: "1"