1 parent 00ffaa3 commit 2d51ebdCopy full SHA for 2d51ebd
1 file changed
src/core/jsonutil.h
@@ -64,7 +64,13 @@ static std::list<std::string> commasplit(std::string&& s)
64
65
static bool to_bool(const nlohmann::json& j, bool dflt)
66
{
67
- return (j.type() == nlohmann::json::value_t::boolean) ? j.get<bool>() : dflt;
+ if (j.type() == nlohmann::json::value_t::boolean) return j.get<bool>();
68
+ else if (j.type() == nlohmann::json::value_t::string) {
69
+ auto s = j.get<std::string>();
70
+ if (strcasecmp(s.c_str(), "true") == 0) return true;
71
+ if (strcasecmp(s.c_str(), "false") == 0) return false;
72
+ }
73
+ return dflt;
74
}
75
static std::string to_string(const nlohmann::json& j, const std::string& dflt)
76
0 commit comments