Move TwitchUser deserialization to the proper Deserialize function

instead of ::fromJSON
This commit is contained in:
Rasmus Karlsson
2018-06-27 00:17:05 +00:00
parent f76512c31e
commit e9868fdd84
3 changed files with 58 additions and 27 deletions
-23
View File
@@ -4,27 +4,4 @@
namespace chatterino {
TwitchUser TwitchUser::fromJSON(const rapidjson::Value &value)
{
TwitchUser user;
if (!value.IsObject()) {
throw std::runtime_error("JSON value is not an object");
}
if (!rj::getSafe(value, "_id", user.id)) {
throw std::runtime_error("Missing ID key");
}
if (!rj::getSafe(value, "name", user.name)) {
throw std::runtime_error("Missing name key");
}
if (!rj::getSafe(value, "display_name", user.displayName)) {
throw std::runtime_error("Missing display name key");
}
return user;
}
} // namespace chatterino