mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
JsonValue: Add as_array() and as_object().
This commit is contained in:
parent
dd36f797d5
commit
8392c549a3
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue