|
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
This function returns true iff the JSON type is primitive (string, number, boolean, or null).
- Returns
true if type is primitive (string, number, boolean, or null), false otherwise.
- Complexity
- Constant.
- Example
- The following code exemplifies is_primitive for all JSON types.
10 json j_number_integer = 17; 11 json j_number_float = 23.42; 12 json j_object = {{ "one", 1}, { "two", 2}}; 13 json j_array = {1, 2, 4, 8, 16}; 14 json j_string = "Hello, world"; 17 std::cout << std::boolalpha; a class to store JSON values
namespace for Niels Lohmann
bool is_primitive() const noexcept return whether type is primitive
Output (play with this example online): true
true
true
true
false
false
true
The example code above can be translated withg++ -std=c++11 -Isrc doc/examples/is_primitive.cpp -o is_primitive
- Since
- version 1.0.0
Definition at line 1938 of file json.hpp.
|