• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# <small>nlohmann::basic_json::</small>json_base_class_t
2
3```cpp
4using json_base_class_t = detail::json_base_class<CustomBaseClass>;
5```
6
7The base class used to inject custom functionality into each instance of `basic_json`.
8Examples of such functionality might be metadata, additional member functions (e.g., visitors), or other application-specific code.
9
10## Template parameters
11
12`CustomBaseClass`
13:   the base class to be added to `basic_json`
14
15## Notes
16
17#### Default type
18
19The default value for `CustomBaseClass` is `void`. In this case an
20[empty base class](https://en.cppreference.com/w/cpp/language/ebo) is used and no additional functionality is injected.
21
22#### Limitations
23
24The type `CustomBaseClass` has to be a default-constructible class.
25`basic_json` only supports copy/move construction/assignment if `CustomBaseClass` does so as well.
26
27## Examples
28
29??? example
30
31    The following code shows how to inject custom data and methods for each node.
32
33    ```cpp
34    --8<-- "examples/json_base_class_t.cpp"
35    ```
36
37    Output:
38
39    ```json
40    --8<-- "examples/json_base_class_t.output"
41    ```
42
43## Version history
44
45- Added in version 3.12.0.
46