From 6d24711208e60ad4ef85c2d055bd49af120e8f77 Mon Sep 17 00:00:00 2001 From: Antony Woods Date: Thu, 6 Nov 2014 14:10:38 +0000 Subject: Added boolean types to json rvalue (.b()) including tests --- include/json.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/json.h b/include/json.h index d79fe88..3fc0911 100644 --- a/include/json.h +++ b/include/json.h @@ -284,6 +284,15 @@ namespace crow return boost::lexical_cast(start_, end_-start_); } + bool b() const + { +#ifndef CROW_JSON_NO_ERROR_CHECK + if (t() != type::True && t() != type::False) + throw std::runtime_error("value is not boolean"); +#endif + return t() == type::True; + } + void unescape() const { if (*(start_-1)) -- cgit v1.2.3-54-g00ecf