From 5b1991102534ecce1784da6282b6ceced4687e3e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 8 Jul 2019 14:06:03 +0200 Subject: [PATCH] AK: Add JsonValue::to_bool(). --- AK/JsonValue.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AK/JsonValue.h b/AK/JsonValue.h index c220924009..0c2a4555af 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -67,6 +67,13 @@ public: return IPv4Address::from_string(as_string()); } + bool to_bool(bool default_value = false) const + { + if (!is_bool()) + return default_value; + return as_bool(); + } + int as_int() const { ASSERT(is_int());