nlohmann::basic_json::is_null - renxiaobo27/json GitHub Wiki
bool is_null() const;Returns whether JSON container has type null.
None.
true of value type is null, 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_null() << '\n';
std::cout << std::boolalpha << j_boolean.is_null() << '\n';
std::cout << std::boolalpha << j_number.is_null() << '\n';
std::cout << std::boolalpha << j_object.is_null() << '\n';
std::cout << std::boolalpha << j_array.is_null() << '\n';
std::cout << std::boolalpha << j_string.is_null() << '\n';
}true
false
false
false
false
false
-
is_boolean
whether value is boolean -
is_number
whether value is number -
is_object
whether value is object -
is_array
whether value is array -
is_string
whether value is string