【发布时间】:2015-12-06 04:20:33
【问题描述】:
我正在尝试解析 yaml usign yaml-cpp。这是我的 yaml:
---
configuration:
- height: 600
- widht: 800
- velocity: 1
- scroll: 30
types:
- image: resources/images/grass.png
name: grass
- image: resources/images/water.png
name: water
version: 1.0
当我这样做时
YAML::Node basenode = YAML::LoadFile("./path/to/file.yaml");
int height;
if(basenode["configuration"])
if(basenode["configuration"]["height"]
height = basenode["configuration"]["height"].as<int>();
else
cout << "The node height doesn't exist" << endl;
else
cout << "The node configuration doesn't exist" << endl;
我收到消息:“节点高度不存在”。如何访问该字段(以及其他字段?)
非常感谢!
【问题讨论】: