Files
json/api/json_sax/parse_error.md
T
2026-10-03 05:43:12 +00:00

51 lines
984 B
Markdown

# <small>nlohmann::json_sax::</small>parse_error
```cpp
virtual bool parse_error(std::size_t position,
const std::string& last_token,
const detail::exception& ex) = 0;
```
A parse error occurred.
## Parameters
`position` (in)
: the position in the input where the error occurs
`last_token` (in)
: the last read token
`ex` (in)
: an exception object describing the error
## Return value
Whether parsing should proceed (**must return `#!cpp false`**).
## Examples
??? example
The example below shows how the SAX interface is used.
```cpp
--8<-- "examples/sax_parse.cpp"
```
Output:
```json
--8<-- "examples/sax_parse.output"
```
## See also
- [sax_parse](../basic_json/sax_parse.md) - SAX parser
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - the article on handling parse errors without
exceptions
## Version history
- Added in version 3.2.0.