我尝试使用 ptree 在 C++ 中获取键值,因为键名有多个 .在键中。
所以我有 json,
"product": {
"product.description.text": "Some text here"
}
我试过打电话
std::string product = pt.get_value("product.product.description.text");
但是取不到值。 请帮助我
最佳答案
根据 http://www.boost.org/doc/libs/1_43_0/doc/html/boost_propertytree/accessing.html 您可以使用如下内容:
pt.get<std::string>('/', "product/product.description.text");
关于c++ - 如果键名带有点(.),则在 C++ 中使用 ptree 从 json 中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31340974/