added failsafe in case the value read by json_string_value is not a string

This commit is contained in:
2024-08-26 11:01:46 +02:00
parent f6aae32288
commit c14a5245b1
+5 -1
View File
@@ -38,7 +38,11 @@ inline int json_int(json_t* object, int default_value = 0) {
inline std::string json_string(json_t* object, std::string default_value = "") {
if (object) {
return std::string(json_string_value(object));
if (json_string_value(object)) {
return std::string(json_string_value(object));
} else {
return default_value;
}
} else {
return default_value;
}