Mercurial > minori
diff src/core/json.cc @ 202:71832ffe425a
animia: re-add kvm fd source
this is all being merged from my wildly out-of-date laptop. SORRY!
in other news, I edited the CI file to install the wayland client
as well, so the linux CI build might finally get wayland stuff.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Tue, 02 Jan 2024 06:05:06 -0500 |
parents | 9b10175be389 |
children |
line wrap: on
line diff
--- a/src/core/json.cc Sun Nov 19 19:13:28 2023 -0500 +++ b/src/core/json.cc Tue Jan 02 06:05:06 2024 -0500 @@ -1,19 +1,13 @@ #include "core/json.h" +#include "json/json.hpp" namespace JSON { -std::string GetString(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, std::string def) { - if (json.contains(ptr) && json[ptr].is_string()) - return json[ptr].get<std::string>(); +nlohmann::json GetValue(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr) { + if (json.contains(ptr)) + return json.at(ptr); else - return def; -} - -int GetInt(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, int def) { - if (json.contains(ptr) && json[ptr].is_number()) - return json[ptr].get<int>(); - else - return def; + return nlohmann::json(); } bool GetBoolean(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, bool def) { @@ -23,11 +17,4 @@ return def; } -double GetDouble(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, double def) { - if (json.contains(ptr) && json[ptr].is_number()) - return json[ptr].get<double>(); - else - return def; -} - } // namespace JSON