-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathJson.cpp
More file actions
47 lines (45 loc) · 1.25 KB
/
Copy pathJson.cpp
File metadata and controls
47 lines (45 loc) · 1.25 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*************************************************************************
> File Name: Json.cpp
> Author: Netcan
> Blog: https://netcan.github.io/
> Mail: netcan1996@gmail.com
> Created Time: 2021-01-23 13:53
************************************************************************/
#include <iostream>
#include <variant>
#include <vector>
#include <map>
using namespace std;
struct JsonValue;
using JsonArray = vector<JsonValue>;
using JsonObject = map<string, JsonValue>;
struct JsonValue:
variant<bool,
long,
double,
std::string,
nullptr_t,
JsonArray,
JsonObject> {
using variant::variant;
};
int main(int argc, char** argv) {
JsonValue value = JsonObject {
{ "widget", JsonObject {
{"debug", false},
{"window", JsonObject {
{"title", "Sample Widget"},
{"name", "main window"},
{"width", 500},
{"height", 500} }
},
{"image", JsonObject {
{"src", "image/sun.png"},
{"name", "sum"},
{"offset", JsonArray{250, 250}},
{"alignment", "center"} }
}},
}
};
return 0;
}