nlohmann::basic_json::is_boolean - renxiaobo27/json GitHub Wiki
bool is_boolean() const;Returns whether JSON container has type boolean.
None.
true of value type is boolean, false otherwise.
Constant.
None. The function's noexcept-specification is noexcept.
#include <iostream>
#include <json.hpp>
int main()
{
nlohmann::json j_null;
nlohmann::json j_boolean = true;
nlohmann::json j_number = 17;
nlohmann::json j_object = {{"one", 1}, {"two", 2}};
nlohmann::json j_array = {1, 2, 4, 8, 16};
nlohmann::json j_string = "Hello, world";
std::cout << std::boolalpha << j_null.is_boolean() << '\n';
std::cout << std::boolalpha << j_boolean.is_boolean() << '\n';
std::cout << std::boolalpha << j_number.is_boolean() << '\n';
std::cout << std::boolalpha << j_object.is_boolean() << '\n';
std::cout << std::boolalpha << j_array.is_boolean() << '\n';
std::cout << std::boolalpha << j_string.is_boolean() << '\n';
}false
true
false
false
false
false