JSON for Modern C++ 是一个由德国大牛 nlohmann 编写的在 C++ 下使用的 JSON 库。 下载地址传送门:json下载 实例代码
#include "json.hpp" using json=nlohmann::json; #include #include #include using namespace std; //json 序列化1 void func1() { json js; js["msg_type"]=2; js["from"]="ds"; js["to"]="cs"; js["msg"]="hello,go go go"; string sendBuf=js.dump(); cout<{"ds","hello world"},{"cn","hello china"}}; cout<vec; vec.push_back(1); vec.push_back(3); vec.push_back(4); vec.push_back(5); js["list"]=vec; //序列化一个map容器 mapm; m.insert({1,"ds"}); m.insert({2,"cn"}); m.insert({3,"co"}); m.insert({4,"os"}); js["path"]=m; string sendBuf=js.dump();//json数据对象 ->序列化 json字符串 cout<
上一篇 Response设置响应数据功能介绍及重定向
下一篇 关于单片机的led灯的二三事,初学者的开端
版权所有 (c)2021-2022 MSHXW.COM
ICP备案号:晋ICP备2021003244-6号