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