diff options
author | Antony Woods <acron1@gmail.com> | 2014-11-06 14:10:38 +0000 |
---|---|---|
committer | Antony Woods <acron1@gmail.com> | 2014-11-06 14:10:38 +0000 |
commit | 6d24711208e60ad4ef85c2d055bd49af120e8f77 (patch) | |
tree | 439b6f75a9214cdb59eed42127d292528ecc99c5 /include/json.h | |
parent | 4b3b8070e75ce0fc181e5c012c47da2a1e7a918e (diff) | |
download | crow-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.h | 9 |
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)) |