题
是否可以使用 yaml-cpp 解析 YAML 格式的字符串?
没有一个 YAML::Parser::Parser(std::string&)
构造函数。(我通过 libcurl 从 http 服务器获取 YAML 字符串。)
解决方案
尝试使用 stringstream的:
std::string s = "name: YAML from libcurl";
std::stringstream ss(s);
YAML::Parser parser(ss);
其他提示
在新版本中,您可以直接解析字符串(参见 这里):
YAML::Node node = YAML::Load("[1, 2, 3]");
不隶属于 StackOverflow