Add support for non-highlight channel point rewards (#1809)
This commit is contained in:
@@ -28,5 +28,22 @@ namespace rj {
|
||||
return std::string(buffer.GetString());
|
||||
}
|
||||
|
||||
bool getSafeObject(rapidjson::Value &obj, const char *key,
|
||||
rapidjson::Value &out)
|
||||
{
|
||||
if (!checkJsonValue(obj, key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
out = obj[key].Move();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool checkJsonValue(const rapidjson::Value &obj, const char *key)
|
||||
{
|
||||
return obj.IsObject() && !obj.IsNull() && obj.HasMember(key);
|
||||
}
|
||||
|
||||
} // namespace rj
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -67,20 +67,12 @@ namespace rj {
|
||||
arr.PushBack(pajlada::Serialize<Type>::get(value, a), a);
|
||||
}
|
||||
|
||||
bool checkJsonValue(const rapidjson::Value &obj, const char *key);
|
||||
|
||||
template <typename Type>
|
||||
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
|
||||
{
|
||||
if (!obj.IsObject())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!obj.HasMember(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.IsNull())
|
||||
if (!checkJsonValue(obj, key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -100,6 +92,9 @@ namespace rj {
|
||||
return !error;
|
||||
}
|
||||
|
||||
bool getSafeObject(rapidjson::Value &obj, const char *key,
|
||||
rapidjson::Value &out);
|
||||
|
||||
std::string stringify(const rapidjson::Value &value);
|
||||
|
||||
} // namespace rj
|
||||
|
||||
Reference in New Issue
Block a user