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 = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>>
JSON_HEDLEY_RETURNS_NON_NULL const char * nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::type_name |
( |
| ) |
const |
|
inlinenoexcept |
return the type as string
Returns the type name as string to be used in error messages - usually to indicate that a function was called on a wrong JSON type.
- Returns
- a string representation of a the m_type member:
Value type | return value |
null | "null" |
boolean | "boolean" |
string | "string" |
number | "number" (for all number types) |
object | "object" |
array | "array" |
binary | "binary" |
discarded | "discarded" |
@exceptionsafety No-throw guarantee: this function never throws exceptions.
@complexity Constant.
@liveexample{The following code exemplifies type_name()
for all JSON types.,type_name}
- See also
- see type() – return the type of the JSON value
-
see operator value_t() – return the type of the JSON value (implicit)
- Since
- version 1.0.0, public since 2.1.0,
const char*
and noexcept
since 3.0.0
Definition at line 24883 of file json.hpp.
24884 {
24885 {
24886 switch (m_type)
24887 {
24889 return "null";
24890
24892 return "object";
24893
24895 return "array";
24896
24898 return "string";
24899
24901 return "boolean";
24902
24904 return "binary";
24905
24907 return "discarded";
24908
24912 default:
24913 return "number";
24914 }
24915 }
24916 }
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)