JsonValue: Add as_array() and as_object().

This commit is contained in:
Andreas Kling 2019-06-24 12:03:31 +02:00
parent dd36f797d5
commit 8392c549a3
Notes: sideshowbarker 2024-07-19 13:29:35 +09:00

View file

@ -46,9 +46,20 @@ public:
String as_string() const
{
if (m_type == Type::String)
return *m_value.as_string;
return { };
ASSERT(is_string());
return *m_value.as_string;
}
const JsonObject& as_object() const
{
ASSERT(is_object());
return *m_value.as_object;
}
const JsonArray& as_array() const
{
ASSERT(is_array());
return *m_value.as_array;
}
Type type() const { return m_type; }