Ask Your Question

dashuo's profile - activity

2016-02-24 02:04:52 -0600 asked a question Issue when write yaml file (C++)

the content of the yaml file I hope is

AAA:
   -  BBB:
        a: 1
        b: 2

the code I write is like

FileStorage fw("./config.yaml", FileStorage::WRITE);
fw << "AAA" << "[" << "{";
fw << "BBB" << "{";
fw << "a" << 1;
fw << "b" << 2;
fw << "}"  << "}" << "]";

while the output of config.yaml is like

AAA:
   -  
      BBB:
        a: 1
        b: 2

the "-" and "BBB" are not in a line.

how can I solve this problem?