mirror of
https://github.com/nlohmann/json.git
synced 2025-11-23 19:34:10 +08:00
📝 update sax_parse documentation (#4878)
This commit is contained in:
@@ -51,10 +51,10 @@ The SAX event lister must follow the interface of [`json_sax`](../json_sax/index
|
||||
## Parameters
|
||||
|
||||
`i` (in)
|
||||
: Input to parse from.
|
||||
: Input to parse from
|
||||
|
||||
`sax` (in)
|
||||
: SAX event listener
|
||||
: SAX event listener (must not be null)
|
||||
|
||||
`format` (in)
|
||||
: the format to parse (JSON, CBOR, MessagePack, or UBJSON) (optional, `input_format_t::json` by default), see
|
||||
@@ -83,6 +83,17 @@ return value of the last processed SAX event
|
||||
|
||||
## Exception safety
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Exceptions
|
||||
|
||||
- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token, or
|
||||
empty input like a null `FILE*` or `char*` pointer.
|
||||
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if `to_unicode` fails or surrogate
|
||||
error.
|
||||
- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if `to_unicode` fails.
|
||||
- Throws [`other_error.502`](../../home/exceptions.md#jsonexceptionother_error502) if `sax` is a null pointer.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the SAX
|
||||
@@ -114,6 +125,7 @@ A UTF-8 byte order mark is silently ignored.
|
||||
- Added in version 3.2.0.
|
||||
- Ignoring comments via `ignore_comments` added in version 3.9.0.
|
||||
- Added `ignore_trailing_commas` in version 3.12.1.
|
||||
- Added `json.exception.other_error.502` exception in version 3.12.1.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -903,7 +903,7 @@ A JSON Patch operation 'test' failed. The unsuccessful operation is also printed
|
||||
|
||||
### json.exception.other_error.502
|
||||
|
||||
This exception occurs when a null pointer is passed as SAX handler in [sax_parse](../api/basic_json/sax_parse.md) function.
|
||||
This exception is thrown when a null pointer is passed as SAX event listener to the [sax_parse](../api/basic_json/sax_parse.md) function.
|
||||
|
||||
!!! failure "Example message"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user