当前位置:网站首页>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;
}
边栏推荐
- [Summary] 1396- 60+ VSCode plugins to create a useful editor
- 还有三天忙完
- 网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口
- ROS 环境使用第三方动态链接库(.so)文件
- 你好,我的新名字叫“铜锁/Tongsuo”
- core sound driver详解
- 基础架构之Mongo
- CCNA-子网划分(VLSM)
- 网络基础(二)-Web服务器-简介——WampServer集成服务器软件之Apache+MySQL软件安装流程 & netstat -an之检测计算机的端口是否占用
- Critical Reviews | 南农邹建文组综述全球农田土壤抗生素与耐药基因分布
猜你喜欢

After 23 years of operation, the former "China's largest e-commerce website" has turned yellow...

基于inquirer封装一个控制台文件选择器

ESP8266-Arduino programming example-HC-SR04 ultrasonic sensor driver

经济新闻:错误# 15:初始化libiomp5md。dll,但发现libiomp5md。已经初始化dll。解决方法

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

CCNA-NAT协议(理论与实验练习)
![[Summary] 1396- 60+ VSCode plugins to create a useful editor](/img/e4/65e55d0e4948c011585b72733d4d19.jpg)
[Summary] 1396- 60+ VSCode plugins to create a useful editor

线性筛求积性函数

软件测试13年从业经验的前辈,总结的5条测试就业建议....

DevEco Studio3.0下载失败,提示An unknown error occurred
随机推荐
固定资产可视化智能管理系统
The sixteenth issue of eight-part article Balabala said (MQ)
One year after graduation, I was engaged in software testing and won 11.5k. I didn't lose face to the post-98 generation...
开心的聚餐
常见链表题及其 Go 实现
OSPF详解(4)
MYSQL (Basic) - An article takes you into the wonderful world of MYSQL
Application of time series database in the field of ship risk management
Recommendation | People who are kind to you, don't repay them by inviting them to eat
终端分屏工具Terminalx的使用
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.解决方法
【HMS core】【FAQ】Account Kit、MDM能力、push Kit典型问题合集6
Pytorch foundation -- tensorboard use (1)
【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
基于b/s架构搭建一个支持多路摄像头的实时处理系统 ---- 使用yolo v5 系列模型
《自然语言处理实战入门》---- 文本样本扩展小技巧:使用回译技术进行样本增强
轻量级网络 ESPNetv2
卫星电话是直接与卫星通信还是通过地面站?
第4章 控制执行流程
网络基础(三)01-网络的基础概念——URL地址组成之协议、主机地址、路径和参数&127.0.0.1本地回环地址& 查看网址IP地址并访问之ping空格+网址&netstat -anb查看本机占用端口