diff options
author | ipkn <ipknhama@gmail.com> | 2014-11-12 09:23:21 +0900 |
---|---|---|
committer | ipkn <ipknhama@gmail.com> | 2014-11-12 09:23:21 +0900 |
commit | 21b027774e4c472d27d8726774aad1aaed95ea42 (patch) | |
tree | 07187af58764de4f50fc31cc834a064736b76345 /include | |
parent | 79e8fa19f603fc5d408370a3579ab5a67aa87bbc (diff) | |
parent | 5120b127b0c167e11c9f7c8495b5b407aea32d76 (diff) | |
download | crow-21b027774e4c472d27d8726774aad1aaed95ea42.tar.gz crow-21b027774e4c472d27d8726774aad1aaed95ea42.zip |
Merge pull request #38 from acron0/json-bool
Added boolean types to json rvalue (.b()) including test
Diffstat (limited to 'include')
-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 4fe03a7..68f06a2 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)) |