diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-24 12:03:31 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-24 12:03:31 +0200 |
commit | 8392c549a3f8af09fce0218b680f766f593aaf3a (patch) | |
tree | b4c485a1af35335984dd1bd262b450f8f554ff0e /AK/JsonValue.h | |
parent | dd36f797d5ad2bf16580a9d03914714ee2e0dd0e (diff) | |
download | serenity-8392c549a3f8af09fce0218b680f766f593aaf3a.zip |
JsonValue: Add as_array() and as_object().
Diffstat (limited to 'AK/JsonValue.h')
-rw-r--r-- | AK/JsonValue.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/AK/JsonValue.h b/AK/JsonValue.h index 439429d9d7..f842014d6f 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -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; } |