-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
43 lines (37 loc) · 1.11 KB
/
test.cpp
File metadata and controls
43 lines (37 loc) · 1.11 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
#include "include/json.hpp"
#include <iostream>
int main(){
// writing test
Json json;
json["person"] = Json::Object({
{"name", "John Doe"},
{"age", 3.124},
{"hobbies", Json::Array({
{"running"},
{"singing"},
{"dancing"}
})},
{"address", Json::Object({
{"street", "123 Main St"},
{"city", "Somewhere"},
{"zipcode", 12345},
})}});
// parsing test
// JsonParse jsonParse;
// Json parse = jsonParse.parse("large-file.json");
// parse.write("testFile.json");
// for loops
// for(const auto& value : json["person"]["hobbies"]){
// // std::cout << value.first << ' ' << *value.second << '\n';
// std::cout << *value << '\n';
// }
//
// JsonObject obj = json["person"]["address"];
// for(const auto& [key, value] : obj){
// std::cout << key << " : " << *value << '\n';
// }
json["person"] += {{"hello", Json::Array({"How", "Are", "You"})}};
json.write("testFile.json");
std::cout << json << std::endl;
return 0;
}