-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
31 lines (30 loc) · 1.15 KB
/
example.cpp
File metadata and controls
31 lines (30 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include "jsoncfg.hpp"
int main(int argc, char *argv[]) {
std::cout << "empty dict: " << jsoncfg::Dict().dumps() << std::endl;
std::cout << "empty list: " << jsoncfg::List().dumps() << std::endl;
auto root_e = jsoncfg::Dict({
{"hello", "world"},
{"list", jsoncfg::List({
1, 3, 224,
224, "float",
jsoncfg::Dict({{"a", 1}, {"b", "2"}}, 0, true),
jsoncfg::List({
1.5, 6, 8,
}, -1, true), jsoncfg::List({1, 2}, 0),
jsoncfg::Dec(31.415926, true, true),
jsoncfg::Uint(0x8000, 16, true),
jsoncfg::Uint(0x0C, 2, true),
}, 3)},
}, 1);
std::cout << root_e.dumps() << std::endl;
std::cout << root_e.dumps(4) << std::endl;
std::cout << root_e.dumps(4, true) << std::endl;
jsoncfg::Json root_d;
root_d.loads(root_e.dumps(4, true));
std::cout << root_d.dumps() << std::endl;
root_d.as<jsoncfg::Dict>()->get("list").as<jsoncfg::List>()[-1].as<jsoncfg::Int>()->base(10);
root_d["list"][3].as<jsoncfg::Uint>() = 512;
std::cout << root_d.dumps(4, true) << std::endl;
return 0;
}