【发布时间】:2018-09-21 19:57:40
【问题描述】:
我正在使用 c++ 并且有一个如下所示的 yaml 文件:
Food:
Apple:
- Type: grannysmith
BellPepper:
- Type: Red
- Type: Green
Sandwich:
- Type: Ham
我需要对其进行解析,以便获得一个仅列出食物名称的字符串向量:output: "Apple", "BellPepper","Sandwich"
到目前为止,我的代码如下所示:
YAML::Node node = YAML::LoadFile(configYamlPath)["Food"];
std::vector<std::string> items;
for (YAML::Node n : node){
items.push_back(n.as<std::string>());
}
我将如何获得这些特定的密钥?
【问题讨论】: