mirror of
https://github.com/nlohmann/json.git
synced 2026-09-30 05:55:46 +00:00
to_bjdata() encoded a JData-annotated object as a BJData ND-array in two cases where from_bjdata() then returned a different value, breaking the documented round-trip guarantee: 1. A "single" element that is finite and in range but not exactly representable as float (e.g. 0.1) or that underflows to 0 (e.g. 1e-300) was silently narrowed instead of falling back to a plain object, unlike out-of-range integer elements. write_bjdata_ndarray() now only accepts a "single" element if it survives the narrowing to float and back, the same criterion write_compact_float() already uses for CBOR/MessagePack. 2. from_bjdata() emitted the annotation keys as _ArraySize_, _ArrayType_, _ArrayData_ instead of the documented _ArrayType_, _ArraySize_, _ArrayData_, because the size key is written while the dimension vector is read, before the type key. For ordered_json, whose comparison takes key order into account, this made a round trip of the documented example compare unequal. The element type marker is known before the dimension vector is read (it precedes '#'), so it is now passed down and the "_ArrayType_" key is emitted first. Fixes #5661. 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.10.2):
git clone https://github.com/nlohmann/json.git
cd json
git checkout v3.10.2
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.