mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
JsonValue: Add as_array() and as_object().
This commit is contained in:
parent
dd36f797d5
commit
8392c549a3
Notes:
sideshowbarker
2024-07-19 13:29:35 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8392c549a3f
1 changed files with 14 additions and 3 deletions
|
@ -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