Utilities/fortune: Replace uses of JsonObject::get_deprecated()/get_ptr

This commit is contained in:
Sam Atkins 2022-12-22 14:27:41 +00:00 committed by Tim Flynn
parent 609a123c43
commit 08c26e988a
Notes: sideshowbarker 2024-07-17 00:51:21 +09:00

View file

@ -27,16 +27,15 @@ public:
return {};
auto& entry = value.as_object();
Quote q;
if (!entry.has("quote"sv) || !entry.has("author"sv) || !entry.has("utc_time"sv) || !entry.has("url"sv))
if (!entry.has_string("quote"sv) || !entry.has_string("author"sv) || !entry.has_u64("utc_time"sv) || !entry.has_string("url"sv))
return {};
// From here on, trust that it's probably fine.
q.m_quote = entry.get_deprecated("quote"sv).as_string();
q.m_author = entry.get_deprecated("author"sv).as_string();
// It is sometimes parsed as u32, sometimes as u64, depending on how large the number is.
q.m_utc_time = entry.get_deprecated("utc_time"sv).to_number<u64>();
q.m_url = entry.get_deprecated("url"sv).as_string();
q.m_quote = entry.get_deprecated_string("quote"sv).value();
q.m_author = entry.get_deprecated_string("author"sv).value();
q.m_utc_time = entry.get_u64("utc_time"sv).value();
q.m_url = entry.get_deprecated_string("url"sv).value();
if (entry.has("context"sv))
q.m_context = entry.get_deprecated("context"sv).as_string();
q.m_context = entry.get_deprecated_string("context"sv).value();
return q;
}