Mercurial > minori
annotate src/core/json.cc @ 174:f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 29 Nov 2023 13:53:56 -0500 |
parents | d02fdf1d6708 |
children | 9b10175be389 |
rev | line source |
---|---|
9 | 1 #include "core/json.h" |
2 | 2 |
3 namespace JSON { | |
4 | |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
5 nlohmann::json GetValue(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr) { |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
6 if (json.contains(ptr)) |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
7 return json.at(ptr); |
9 | 8 else |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
83
diff
changeset
|
9 return nlohmann::json(); |
2 | 10 } |
11 | |
83 | 12 bool GetBoolean(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, bool def) { |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
13 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
|
14 return json[ptr].get<bool>(); |
9 | 15 else |
16 return def; | |
2 | 17 } |
18 | |
9 | 19 } // namespace JSON |