-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.hpp
More file actions
28 lines (26 loc) · 772 Bytes
/
test.hpp
File metadata and controls
28 lines (26 loc) · 772 Bytes
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
class Test {
std::shared_ptr<nlohmann::json> value;
public:
Test(std::shared_ptr<nlohmann::json> value) : value(value) {}
Test(std::string_view json_value) : value(std::make_shared<nlohman::json>(nlohmann::json::parse(json_value))) {}
std::optional<std::string> name() const {
if (value->contains("name")) {
return value->at("name");
} else {
return std::nullopt;
}
}
std::optional<std::string> definitionType() const {
if (value->contains("definitionType")) {
return value->at("definitionType");
} else {
return std::nullopt;
}
}
std::optional<unknown> properties() const {
if (value->contains("properties")) {
return value->at("properties");
} else {
return std::nullopt;
}
}};