• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# <small>nlohmann::basic_json::</small>error_handler_t
2
3```cpp
4enum class error_handler_t {
5    strict,
6    replace,
7    ignore
8};
9```
10
11This enumeration is used in the [`dump`](dump.md) function to choose how to treat decoding errors while serializing a
12`basic_json` value. Three values are differentiated:
13
14strict
15:   throw a `type_error` exception in case of invalid UTF-8
16
17replace
18:   replace invalid UTF-8 sequences with U+FFFD (� REPLACEMENT CHARACTER)
19
20ignore
21:   ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged
22
23## Examples
24
25??? example
26
27    The example below shows how the different values of the `error_handler_t` influence the behavior of
28    [`dump`](dump.md) when reading serializing an invalid UTF-8 sequence.
29
30    ```cpp
31    --8<-- "examples/error_handler_t.cpp"
32    ```
33
34    Output:
35
36    ```json
37    --8<-- "examples/error_handler_t.output"
38    ```
39
40## Version history
41
42- Added in version 3.4.0.
43