Mercurial > minori
annotate src/core/json.cc @ 380:861368fd42ff
about: update email address
| author | Paper <paper@tflc.us> |
|---|---|
| date | Thu, 06 Nov 2025 01:12:39 -0500 |
| parents | 47c9f8502269 |
| children |
| rev | line source |
|---|---|
| 9 | 1 #include "core/json.h" |
| 175 | 2 #include "json/json.hpp" |
| 2 | 3 |
| 4 namespace JSON { | |
| 5 | |
| 369 | 6 nlohmann::json GetValue(const nlohmann::json &json, const nlohmann::json::json_pointer &ptr) |
| 7 { | |
|
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
8 if (json.contains(ptr)) |
|
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
9 return json.at(ptr); |
| 9 | 10 else |
|
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
11 return nlohmann::json(); |
| 2 | 12 } |
| 13 | |
| 369 | 14 bool GetBoolean(const nlohmann::json &json, const nlohmann::json::json_pointer &ptr, bool def) |
| 15 { | |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
16 if (json.contains(ptr) && json[ptr].is_boolean()) |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
17 return json[ptr].get<bool>(); |
| 9 | 18 else |
| 19 return def; | |
| 2 | 20 } |
| 21 | |
| 9 | 22 } // namespace JSON |
