免费个人二级域名网站,科技感强的网站,网页制作教程好看视频,平顶山车祸最新新闻事件json文件示例#xff1a; 代码运行环境VS2019
一、git下载nlohmann库文件源代码
源代码文件目录 二、利用VS2019新建工程#xff0c;并配置项目属性 配置VC目录---包含目录 三、项目源代码
#include iostream
#include fstream
#include nlohmann/jso…json文件示例 代码运行环境VS2019
一、git下载nlohmann库文件源代码
源代码文件目录 二、利用VS2019新建工程并配置项目属性 配置VC目录---包含目录 三、项目源代码
#include iostream
#include fstream
#include nlohmann/json.hpp
#include vector
using namespace std;void readJson(const string filename)
{//读取json数据ifstream ifs(filename);nlohmann::json j nlohmann::json::parse(ifs);string name, sex, age, job;//访问json数据name j[Student][name];sex j[Student][sex];age j[Student][age];cout name: name sex: sex age: age endl;vectorvectorintnumS;numS j[id];for (int i 0;inumS.size();i){for (int j 0;jnumS[i].size();j){cout numS[i][j] ;}cout endl;}
}int main()
{string path .\\data.json;readJson(path);return 0;
}四、运行结果