added failsafe in case the value read by json_string_value is not a string
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user