diff --git a/toREST/include/util.hpp b/toREST/include/util.hpp index ee9e243..ceef9f5 100644 --- a/toREST/include/util.hpp +++ b/toREST/include/util.hpp @@ -74,20 +74,10 @@ public: } return nlohmann::json(nullptr); } - static bool has_property(const std::string &key, const nlohmann::json &object) { - auto it = object.find(key); - return it != object.end(); - } template - static auto get(const std::string &key, const nlohmann::json &object, const T &default_value) { - if (has_property(key, object)) { - T r; - try { - r = object[key]; //TODO fix use json parser where a non-throwable exist - } catch (const std::exception &) { - return default_value; - } - return r; + static T get(const std::string &key, const nlohmann::json &object, const T &default_value) { + if (object.find(key) != object.end()) { + return object[key]; } return default_value; }