'hbp-Common-stage-01': {
short_component_id: "cm01",
internal_ip: "172.16.80.3"
}
hbp-Common-stage-02:
internal_ip_: 172.16.95.245
short_component_id_: cm02
这两个格式到底有什么不同?
为什么我用下面的解析方法,前者能解析后者不能?
if (config["hosts"]) {
YAML::Node hosts_config = config["hosts"];
for (const auto &it : hosts_config) {
auto hbp_stage_one = it.first.as<std::string>();
HostConfig host_config_one{};
if (it.second["short_component_id"]) {
host_config_one.short_component_id_ =
it.second["short_component_id"].as<std::string>();
qDebug() << "nnnnnnnnnnñ " << endl;
}
if (it.second["internal_ip"]) {
host_config_one.internal_ip_ =
it.second["internal_ip"].as<std::string>();
}
if (it.second["kafka_group_id"]) {
host_config_one.kafka_group_id_ =
it.second["kafka_group_id"].as<std::string>();
}
if (it.second["reconnect_hostname"]) {
host_config_one.reconnect_hostname_ =
it.second["reconnect_hostname"].as<std::string>();
}
if (it.second["trivial_transaction_generator_"]) {
host_config_one.trivial_transaction_generator_ =
it.second["trivial_transaction_generator"].as<std::string>();
}
不知道你这个问题是否已经解决, 如果还没有解决的话: