使用现代C++编写的读写json的库
2017-12-09 10:51
337 查看
本库支持C++2017,它是来源自:https://github.com/nlohmann/json
项目,为了测试使用这个库,其实只要下载一个文件即可,就是json.hpp,然后就可以使用了。
现在就来写一个简单的例子来测试一下,完整的项目代码在:http://download.csdn.net/download/caimouse/10151902
这个例子输出如下:
深入浅出Numpy
五子棋游戏开发
http://edu.csdn.net/course/detail/5487
项目,为了测试使用这个库,其实只要下载一个文件即可,就是json.hpp,然后就可以使用了。
现在就来写一个简单的例子来测试一下,完整的项目代码在:http://download.csdn.net/download/caimouse/10151902
// ConsoleApplication1.cpp: 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <string> #include <iostream> #include "json.hpp" using namespace nlohmann; int main() { // a JSON text std::string text = R"( { "Image": { "Width": 800, "Height": 600, "Title": "View from 15th Floor", "Thumbnail": { "Url": "http://www.example.com/image/481989943", "Height": 125, "Width": 100 }, "Animated" : false, "IDs": [116, 943, 234, 38793] } } )"; // parse and serialize JSON json j_complete = json::parse(text); std::cout << std::setw(4) << j_complete << "\n\n"; // define parser callback json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed) { // skip object elements with key "Thumbnail" if (event == json::parse_event_t::key and parsed == json("Thumbnail")) { return false; } else { return true; } }; // parse (with callback) and serialize JSON json j_filtered = json::parse(text, cb); std::cout << std::setw(4) << j_filtered << '\n'; }
这个例子输出如下:
深入浅出Numpy
http://edu.csdn.net/course/detail/6149
Python游戏开发入门
http://edu.csdn.net/course/detail/5690你也能动手修改C编译器
http://edu.csdn.net/course/detail/5582纸牌游戏开发
http://edu.csdn.net/course/detail/5538
五子棋游戏开发
http://edu.csdn.net/course/detail/5487
RPG游戏从入门到精通
http://edu.csdn.net/course/detail/5246
WiX安装工具的使用
http://edu.csdn.net/course/detail/5207
俄罗斯方块游戏开发
http://edu.csdn.net/course/detail/5110
boost库入门基础
http://edu.csdn.net/course/detail/5029
Arduino入门基础
http://edu.csdn.net/course/detail/4931
Unity5.x游戏基础入门
http://edu.csdn.net/course/detail/4810
TensorFlow API攻略
http://edu.csdn.net/course/detail/4495
TensorFlow入门基本教程
http://edu.csdn.net/course/detail/4369
C++标准模板库从入门到精通
http://edu.csdn.net/course/detail/3324
跟老菜鸟学C++
http://edu.csdn.net/course/detail/2901
跟老菜鸟学python
http://edu.csdn.net/course/detail/2592
在VC2015里学会使用tinyxml库
http://edu.csdn.net/course/detail/2590
在Windows下SVN的版本管理与实战
http://edu.csdn.net/course/detail/2579
Visual Studio 2015开发C++程序的基本使用
http://edu.csdn.net/course/detail/2570
在VC2015里使用protobuf协议
http://edu.csdn.net/course/detail/2582
在VC2015里学会使用MySQL数据库
http://edu.csdn.net/course/detail/2672
相关文章推荐
- c++ 使用boost去读写json
- C++使用json二维数组格式读写二进制文件
- Linux下,使用C/C++编写一个简单的消息处理程序
- 在C#中使用C++编写的类
- 在C++中使用C#编写的类
- 使用c++开发excel插件 (3.4、编写一个简单的动态链接库)
- 使用Delphi调用C++编写的DLL
- 使用Borland C++ Builder来编写DLLs
- Classic ASP 使用jqGrid实现读写删(json)
- MFC中使用C++ 读写文件
- 使用 C++ 编写内核模式驱动程序的优点与缺点
- c++游戏开发中使用json
- 使用 C++ 编写内核模式驱动程序的优点与缺点
- 如何使用C++编写CGI程序接口
- 使用c++开发excel插件(第4章编写一个完整的xll)
- Linux下,使用C/C++编写"静态链接库"的一个简单例子
- 使用C++编写类似MFC的CString,部分功能,重新复习使用操作符重载
- [C++]实验一:使用VC++6.0环境编写C++程序
- ASP 使用jqGrid实现读写删的代码(json)
- Linux下,使用C/C++编写的一个简单的信号处理例程