使用Boost的JSON数据
JSON Data using Boost
是否可以使用Boost读取以下数据?
{
"ok": true,
"result": [
{
"update_id": 1235285,
"message": {
"message_id": 2,
"from": {
"id": 3325446,
"is_bot": false,
"first_name": "Test",
"language_code": "en-PH"
},
"chat": {
"id": 12532541,
"first_name": "Test Account",
"type": "private"
},
"date": 152014521,
"text": "Test Message"
}
}
]
}
您可以在评论中看到链接的帖子
总而言之,您可以喜欢从文件中读取mfile.json
:
boost::property_tree::ptree pt;
boost::property_tree::read_json("myfile.json", pt);
print_contents( pt );
其中 print_contents
是:
void print_contents( const boost::property_tree::ptree& pt)
{
using boost::property_tree::ptree;
for (const auto& x: pt )
{
std::cout << x.first << ": " << x.second.get_value<std::string>() << std::endl;
print_contents(x.second);
}
}
See Here
我本可以重复关闭它,但是看起来没有"更好"的帖子来读取JSON文件
相关文章:
- 如何使用curlpp通过POST方法上传文件和json数据
- 如何在Visual C+++中从JSON文件中读取节点数据
- 如何将 json 数据附加到 Qt 中的现有 json 文件中
- 通过TCP将数据从C++客户端发送到JSON服务器
- 修复错误的 JSON 数据
- 从 JSON 读取和保存数据
- 使用 JSONCPP 将 JSON 数据增量写入文件
- 使用 jsoncpp 时从 JSon 剥离私有数据的最佳方法
- 如何将 JSON 键值(我使用 cpp boost 解析)存储在相关数据结构中?
- 如何使用 C++ 中的 cpprestsdk 发布 json 数据并从本地服务器获取响应
- 比较 JSON::Value 变量中的数据,然后更新到文件
- 使用 C++ 解析 URL 中的 JSON 数据
- curl发送JSON数据不使用C 工作
- 如何使用NLHOMAN JSON将相同的密钥JSON数据合并到C 中
- 是否可以从OpenPose库中实时输出JSON数据
- 使用Nlohmann JSON将JSON数据保存在文件中时获取空值
- 如何将变量用作原始 JSON 字符串中的数据?
- 如何将 JSON 数据发送到 REST API?
- 如何以json格式保存弹性搜索的数据
- c++ rest sdk POST表单数据json