【问题标题】:Get value from json using ptree in c++ if key name is with dots(.)如果键名带有点(。),则在 c++ 中使用 ptree 从 json 中获取值
【发布时间】:2015-09-29 05:09:35
【问题描述】:

我尝试使用 ptree 在 c++ 中获取键的值,以获得具有多个 .在键中。

所以我有 json,

"product": {
    "product.description.text": "Some text here"
}

我试着打电话

std::string product = pt.get_value("product.product.description.text");

但无法获得价值。 请帮帮我

【问题讨论】:

    标签: c++ json ptree


    【解决方案1】:

    根据http://www.boost.org/doc/libs/1_43_0/doc/html/boost_propertytree/accessing.html 您可以使用以下内容:

    pt.get<std::string>('/', "product/product.description.text");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-31
      相关资源
      最近更新 更多