mirror of
https://github.com/nlohmann/json.git
synced 2026-11-12 23:20:46 +00:00
deploy: cdfb130fa6
This commit is contained in:
1 parent
8ddeea7128
commit
5097c20962
516 files changed
+7306
-5984
No files matched your search
@@ -104,7 +104,7 @@ Parsing into a document instead of a value
|
||||
|
||||
Performance
|
||||
|
||||
Contiguous inputs (strings, string views, vectors, arrays, pointer ranges) are the fastest to parse. A `std::istream` comes close: the parser scans the characters its stream buffer holds in bulk, without reading ahead, so the stream is left exactly where it would be after reading one character at a time. A `FILE*` is read one character at a time, but the file is locked only once, so other threads that use the same `FILE` object wait until parsing is done. See [input sources and performance](https://json.nlohmann.me/features/parsing/#input-sources-and-performance), [`JSON_DISABLE_STREAM_BULK_SCAN`](https://json.nlohmann.me/api/macros/json_disable_stream_bulk_scan/index.md), and [`JSON_DISABLE_UNLOCKED_FILE_IO`](https://json.nlohmann.me/api/macros/json_disable_unlocked_file_io/index.md).
|
||||
Contiguous inputs (strings, string views, vectors, arrays, pointer ranges) are the fastest to parse. A `std::istream` comes close: the parser scans the characters its stream buffer holds in bulk, without reading ahead, so the stream is left exactly where it would be after reading one character at a time. With glibc and the Apple C library, the characters the `FILE` holds in its buffer are scanned in bulk like a stream's; elsewhere a `FILE*` is read one character at a time. Where the C library has unlocked stdio functions, the file is locked only once, so other threads that use the same `FILE` object wait until parsing is done, unless [`JSON_DISABLE_UNLOCKED_FILE_IO`](https://json.nlohmann.me/api/macros/json_disable_unlocked_file_io/index.md) is defined to `1`. See [input sources and performance](https://json.nlohmann.me/features/parsing/#input-sources-and-performance) and [`JSON_DISABLE_STREAM_BULK_SCAN`](https://json.nlohmann.me/api/macros/json_disable_stream_bulk_scan/index.md).
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -698,6 +698,7 @@ Output:
|
||||
- Extended overload (2) to accept heterogeneous iterator+sentinel pairs (C++20 ranges support) in version 3.13.0 unreleased.
|
||||
- `JSON_STRICT_NUL_HANDLING` added in version 3.13.0 unreleased to optionally reject a NUL byte in the input instead of treating it as end of input; planned to become the default in version 4.0.0.
|
||||
- Extended empty-input detection to also cover an `std::istream` without a stream buffer, and fixed a crash (`std::terminate`) when parsing from an `std::istream` with `eofbit` in its exception mask, in version 3.13.0 unreleased.
|
||||
- Fixed the position that a [`parse_error.101`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error101) reports for an unexpected number that is followed by a line feed in version 3.13.0 unreleased: for the input `1`, line feed, `2`, line feed, version 3.12.0 reported "line 2, column 0" and version 3.13.0 unreleased reports "line 2, column 1"; for `1 2` and a line feed, the report was "line 1, column 0" and is now "line 1, column 3".
|
||||
- Parsing from an `std::istream` scans the characters in its stream buffer in bulk in version 3.13.0 unreleased ([`JSON_DISABLE_STREAM_BULK_SCAN`](https://json.nlohmann.me/api/macros/json_disable_stream_bulk_scan/index.md) restores reading one character at a time).
|
||||
- Parsing from a `FILE*` locks the file once instead of once per character in version 3.13.0 unreleased ([`JSON_DISABLE_UNLOCKED_FILE_IO`](https://json.nlohmann.me/api/macros/json_disable_unlocked_file_io/index.md) restores `std::fgetc`).
|
||||
- Ill-formed UTF-16 and UTF-32 input (a lone surrogate, a high surrogate that is not followed by its low surrogate, or a code point above `U+10FFFF`) is rejected with `parse_error.101` in version 3.13.0 unreleased; before that, some such sequences were accepted or ended the input silently.
|
||||
|
||||
Reference in new issue
Block a user