#ifndef UTILS_FUNCTIONS_HPP_ #define UTILS_FUNCTIONS_HPP_ #include struct functions { static inline std::string isNull(const nlohmann::json& str) { return str.is_null() ? str.dump() : str.get(); } template static std::optional testValue(const nlohmann::json& data, const std::vector& keys) { const nlohmann::json* current = &data; for (const auto& key : keys) { if (current->contains(key)) { current = &(*current)[key]; } else { return std::nullopt; } } if constexpr (std::is_same_v) { if (current->is_boolean()) { return current->get(); } } else if constexpr (std::is_same_v) { if (current->is_number_integer()) { return current->get(); } } else if constexpr (std::is_same_v) { if (current->is_number_float()) { return current->get(); } } else if constexpr (std::is_same_v) { if (current->is_string()) { return current->get(); } } return std::nullopt; } }; #endif