当前位置:网站首页>nlohmann json 使用指南【visual studio 2022】
nlohmann json 使用指南【visual studio 2022】
2022-07-30 18:35:00 【一只公羊】
一、JSON for Modern C++
官网:https://github.com/nlohmann/json
下载:https://github.com/nlohmann/json/releases

二、集成到 visual studio 2022
2.1 解压include.zip,拷贝include下的include到工程文件夹下:
2.2. 修改工程属性里的:附加包含目录
2.3 测试
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
json j; //首先创建一个空的json对象
j["pi"] = 3.141; //然后通过名称/值对的方式进行初始化,此时名称"pi"对应的数值就是3.141
j["happy"] = true; //将名称"happy"赋值为true
j["name"] = "Niels"; //将字符串"Niels"存储到"name"
j["nothing"] = nullptr; //"nothing"对应的是空指针
j["answer"]["everything"] = 42; //对对象中的对象进行初始化
j["list"] = {
1, 0, 2}; //使用列表初始化的方法对"list"数组初始化
j["object"] = {
{
"currency", "USD"}, {
"value", 42.99}}; //对对象进行初始化
std::string s = j.dump(); // {"happy":true,"pi":3.141}
std::cout << j.dump(4) << std::endl;
return 0;
}
边栏推荐
- Anaconda Navigator stuck on loading applications
- Chapter 4 Controlling the Execution Flow
- 尊重客观事实
- 第14章 类型信息
- CCNA-网络汇总 超网(CIDR) 路由最长掩码匹配
- 不同的路径依赖
- 【AGC】构建服务1-云函数示例
- Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group
- 终端分屏工具Terminalx的使用
- 基于b/s架构搭建一个支持多路摄像头的实时处理系统 ---- 使用yolo v5 系列模型
猜你喜欢

时序数据库在船舶风险管理领域的应用

One year after graduation, I was engaged in software testing and won 11.5k. I didn't lose face to the post-98 generation...

DTSE Tech Talk丨第2期:1小时深度解读SaaS应用系统设计

Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group

【剑指 Offe】剑指 Offer 18. 删除链表的节点

荐书 | 推荐好评如潮的3本数据库书籍

【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list

3D机器视觉厂商的场景争夺战役

Mysql execution principle analysis

Pytorch foundation -- tensorboard use (1)
随机推荐
6 yuan per catty, why do Japanese companies come to China to collect cigarette butts?
AWS console
MySQL data types
SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
基于inquirer封装一个控制台文件选择器
ROS 环境使用第三方动态链接库(.so)文件
运营 23 年,昔日“国内第一大电商网站”黄了...
CCNA-ACL(访问控制列表)标准ACL 扩展ACL 命名ACL
Presto 中 lookUp Join的实现
core sound driver详解
One year after graduation, I was engaged in software testing and won 11.5k. I didn't lose face to the post-98 generation...
沉浸式体验科大讯飞2022消博会“官方指定产品”
node封装一个控制台进度条插件
cocos creater 热更重启导致崩溃
Application of time series database in the field of ship risk management
scrapy基本使用
MYSQL (Basic) - An article takes you into the wonderful world of MYSQL
mysql的多实例
网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口
猎豹移动终于递交年报:年营收7.85亿 腾讯持股16.6%