• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# basic_json::type
2
3```cpp
4constexpr value_t type() const noexcept;
5```
6
7Return the type of the JSON value as a value from the [`value_t`](value_t.md) enumeration.
8
9## Return value
10
11the type of the JSON value
12
13Value type                | return value
14------------------------- | -------------------------
15`#!json null`             | `value_t::null`
16boolean                   | `value_t::boolean`
17string                    | `value_t::string`
18number (integer)          | `value_t::number_integer`
19number (unsigned integer) | `value_t::number_unsigned`
20number (floating-point)   | `value_t::number_float`
21object                    | `value_t::object`
22array                     | `value_t::array`
23binary                    | `value_t::binary`
24discarded                 | `value_t::discarded`
25
26## Exception safety
27
28No-throw guarantee: this member function never throws exceptions.
29
30## Complexity
31
32Constant.
33
34## Example
35
36??? example
37
38    The following code exemplifies `type()` for all JSON types.
39
40    ```cpp
41    --8<-- "examples/type.cpp"
42    ```
43
44    Output:
45
46    ```json
47    --8<-- "examples/type.output"
48    ```
49
50## Version history
51
52- Added in version 1.0.0.
53- Added unsigned integer type in version 2.0.0.
54- Added binary type in version 3.8.0.
55