mirror of
https://github.com/nlohmann/json.git
synced 2026-09-28 02:30:32 +00:00
PR #5531 fixed the UTF-8-validation gap described in #5529, but it was merged onto the still-unmerged bson-sizes branch rather than develop, so develop was left with the original bug for all affected formats. A follow-up comment on #5529 reproduced this on develop and additionally found that UBJSON (and, by the same code path, BJData) has the identical gap, undocumented. Port the same fix directly onto develop: extract the UTF-8 DFA decoder out of serializer<>::decode() into a shared detail::decode()/is_valid_utf8() in string_utils.hpp, and call it from binary_reader::get_string() - the single choke point shared by all five binary readers - so malformed text strings are rejected at decode time (parse_error.113) instead of only failing later on dump() (type_error.316). Byte/binary payloads are unaffected. Add matching decode-time tests for CBOR, MessagePack, BSON, UBJSON, and BJData, and document the new behavior on all five binary format pages (the two UBJSON/BJData pages didn't get this note in #5531). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017sdieJCn6BHxzRMaXP49sP
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.