play around with the QString json deserializer

This commit is contained in:
Rasmus Karlsson 2018-06-06 11:42:01 +02:00
parent 7f589803be
commit 5724c7ef67
2 changed files with 16 additions and 1 deletions

View file

@ -73,6 +73,10 @@ bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
return false;
}
if (obj.IsNull()) {
return false;
}
try {
out = pajlada::Settings::Deserialize<Type>::get(obj[key]);
} catch (const std::runtime_error &) {

View file

@ -24,7 +24,18 @@ struct Deserialize<QString> {
throw std::runtime_error("Deserialized rapidjson::Value is not a string");
}
return value.GetString();
try {
const char *str = value.GetString();
auto strLen = value.GetStringLength();
return QString::fromUtf8(str, strLen);
} catch (const std::exception &e) {
int x = 5;
} catch (...) {
int y = 5;
}
return QString();
}
};