6

Is it possible to parse YAML formatted strings with yaml-cpp?

There isn't a YAML::Parser::Parser(std::string&) constructor. (I'm getting a YAML string via libcurl from a http-server.)

Jesse Beder
  • 33,081
  • 21
  • 109
  • 146
Jason
  • 63
  • 1
  • 3

2 Answers2

9

Try using a stringstream:

std::string s = "name: YAML from libcurl";
std::stringstream ss(s);
YAML::Parser parser(ss);
Josh Kelley
  • 56,064
  • 19
  • 146
  • 246
7

In the new version, you can parse a string directly (see here):

YAML::Node node = YAML::Load("[1, 2, 3]");
Frank
  • 64,140
  • 93
  • 237
  • 324