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