#include <iostream>
#include <yaml-cpp/yaml.h>
int main() {
// 創(chuàng)建一個(gè)YAML節(jié)點(diǎn)
YAML::Node node;
node["name"] = "John";
node["age"] = 30;
node["city"] = "New York";
// 序列化到字符串
std::string serialized_yaml = YAML::Dump(node);
std::cout << "Serialized YAML:
" << serialized_yaml << std::endl;
// 反序列化從字符串
YAML::Node deserialized_node = YAML::Load(serialized_yaml);
std::cout << "Deserialized YAML:
";
std::cout << deserialized_node << std::endl;
return 0;
}