【发布时间】:2020-10-20 11:21:12
【问题描述】:
nlohmann array_t 与 Nlohmann json array 有何不同? array_t 是如何实际使用的?每个文档如下。
从给定的初始化列表创建一个 JSON 数组值。也就是说,给定值 a、b、c 的列表,创建 JSON 值 [a, b, c]。如果初始化列表为空,则创建空数组 []。
例子,
nlohmann::json j_nonempty_init_list = json::array({1, 2, 3, 4});
std::cout << j_nonempty_init_list;
// [1,2,3,4]
为了在 C++ 中存储对象,类型由下面解释的模板参数定义。
- 模板参数
- ArrayType 用于存储数组的容器类型(例如 std::vector 或 std::list)
- AllocatorType 用于数组的分配器(例如,std::allocator)
【问题讨论】:
标签: c++ nlohmann-json