-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (37 loc) · 1.3 KB
/
main.cpp
File metadata and controls
45 lines (37 loc) · 1.3 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
// Includes required
#include <json/parse.h>
// Using namespace
using namespace json;
int main(int argc, char *argv[]) {
object person;
person["name"] = "Adit";
person["age"] = 21;
person.insert("height", 186.5);
person["alive"] = true;
person["links"]["github"] = "https://github.com/jadit19";
person["links"]["linkedin"] = "https://www.linkedin.com/in/jadit19/";
object college;
college["name"] = "Indian Institute of Technology Kanpur";
college["graduation"] = 2024;
college["major"] = "Electrical Engineering";
college["minors"].push_back("Operating Systems");
college["minors"].push_back("Machine Learning");
college["minors"].resize(3);
college["minors"][2] = "English Literature";
person["college"] = college;
person["languages"].resize(1);
person["languages"][0] = "English";
person["languages"].push_back("Hindi");
person["languages"].push_back("Spanish");
person["languages"][2] = "French";
parser parser;
std::string data = person.dumps();
object duplicate = parser.loads(data);
logger::info(duplicate.dumps(2));
std::string name = person["name"];
int age = person["age"];
bool alive = person["alive"];
logger::info(name + " is " + std::to_string(age) + " years old and is " +
(alive ? "alive" : "dead") + ".");
return EXIT_SUCCESS;
}