Hi, I want to remove some fields(version). I have used remove function but it did not delete that field. #include <iostream> #include <yaml-cpp/yaml.h> #include <fstream> #include<cstring> #define ORIGINAL_FILE "01-network-manager-all.yaml"
using namespace std;
void configureNetplan() {
YAML::Node config = YAML::LoadFile(ORIGINAL_FILE);
ofstream fout(ORIGINAL_FILE);
config["network"]["version"]=2;
config["network"]["renderer"]="networkd";
config["network"]["ethernets"]["eth1"]["dhcp4"]="yes";
config["network"]["ethernets"]["ens33"]["addresses"]="1.2.3.4";
config["network"]["ethernets"]["ens33"]["gateway4"]="1.2.3.4";
config["network"]["ethernets"]["ens33"]["nameservers"]["addresses"]= "1.2.34.3";
node.remove(config["network"]["version"]);
cout<<config;
config["network"]["ethernets"]["ens33"]["dhcp4"]="yes";
fout<<config;
fout.close();
}
int main(int argc,char** argv) { configureNetplan();
return 0; }