aboutsummaryrefslogtreecommitdiffstats
path: root/include/json.h
diff options
context:
space:
mode:
authorAntony Woods <acron1@gmail.com>2014-11-06 14:10:38 +0000
committerAntony Woods <acron1@gmail.com>2014-11-06 14:10:38 +0000
commit6d24711208e60ad4ef85c2d055bd49af120e8f77 (patch)
tree439b6f75a9214cdb59eed42127d292528ecc99c5 /include/json.h
parent4b3b8070e75ce0fc181e5c012c47da2a1e7a918e (diff)
downloadcrow-6d24711208e60ad4ef85c2d055bd49af120e8f77.tar.gz
crow-6d24711208e60ad4ef85c2d055bd49af120e8f77.zip
Added boolean types to json rvalue (.b()) including tests
Diffstat (limited to 'include/json.h')
-rw-r--r--include/json.h9
1 files changed, 9 insertions, 0 deletions
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<double>(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))