mirror of
https://github.com/nlohmann/json.git
synced 2026-10-31 09:55:42 +00:00
json_document::accept() ran the builder that writes the node index and discarded the index. For input without comments and trailing commas it now runs a second instantiation of the builder, with a template parameter Store that is false: the grammar, number, string, UTF-8 and nesting checks are the same code, but no node is written, the container nodes are not patched when they close, the node array is not reserved, and no list of large objects is kept. What only builds the arguments of a node (integer conversion, the digit counts of floats) is not run either. accept() with comments or trailing commas and parse() are not changed; the builder that stores is the one parse() always used. A flag of the document passes the request from accept() to build(). accept() on twitter, citm_catalog, canada and the two minified files, A/B in one binary, 6 code layouts, time after / before (geometric mean of the five; the other 14 files of the set are faster too, none is slower): - Apple M1 Max, Apple clang 21: 0.89 - x86-64 Haswell, GCC 16.2: 0.75 - x86-64 Haswell, Clang 23: 0.78 (semanticscholar-corpus.json: 0.52 on both x86 compilers.) parse() runs the same instructions as before; its timings moved by up to 3 % on a few small files with unchanged instruction counts (code placement). Tests: accept() against json::accept() for the same inputs with all four option combinations and with and without a terminating NUL: 2,000 generated documents and damaged copies of them, nesting from 63 to 1000 levels (closed and not), objects with 300 members, a null byte in the text, and float overflow for a float document. Checked against a deliberately broken validator. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Documentation
Generate documentation
Note on documentation: The source files contain links to the online documentation at https://json.nlohmann.me.
This URL provides the most recent documentation and also applies to previous versions. Documentation for deprecated
functions is not removed; instead, it is marked as deprecated.
If you want to view the documentation for a specific tag or commit hash, you can generate it locally as follows (example
using tag v3.12.0):
git clone https://github.com/nlohmann/json.git
cd json
git checkout v3.12.0
make install_venv serve -C docs/mkdocs
Open http://127.0.0.1:8000/ in your browser. Replace any URL in the source code that points to
https://json.nlohmann.me with http://127.0.0.1:8000 to view the documentation for the selected tag or commit hash.