0

How to add a multi line string as value to key using node ? I don't want to use emitter.

I want something like below code

Iphone: blah ... blah \n blah .... blah \n

I want to create the data similar to above programitically using a YAML::Node object.

Bhanu Vanka
  • 31
  • 1
  • 3

1 Answers1

0

Just set the string in your node:

YAML::Node node;
node["iphone"] = "blah ... blah \n blah .... blah \n"
std::cout << node;

If you're looking to have it output with multiple lines, instead of \n, you'll have to use an emitter; yaml-cpp doesn't support formatting output with basic node dumping. (Feel free to file an issue on the project page if you think it's worthwhile.)

Jesse Beder
  • 33,081
  • 21
  • 109
  • 146