From 5de50cd6c44b7561de0aa29458ec823323f73b49 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 8 Sep 2026 20:19:35 +0200 Subject: [PATCH] Note the 1,048,576 valueless-array limit as (1 << 20) in the docs Addresses review feedback from @gregmarr on PR #5504: spell out the binary/hex form next to the decimal count so it reads as the round power-of-two it is, matching how include/nlohmann/detail/input/binary_reader.hpp defines max_valueless_container_size. Applied in both docs/exceptions.md and ubjson.md, as requested. Signed-off-by: Niels Lohmann --- docs/mkdocs/docs/features/binary_formats/ubjson.md | 5 +++-- docs/mkdocs/docs/home/exceptions.md | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/mkdocs/docs/features/binary_formats/ubjson.md b/docs/mkdocs/docs/features/binary_formats/ubjson.md index 72529a925..be545b9fe 100644 --- a/docs/mkdocs/docs/features/binary_formats/ubjson.md +++ b/docs/mkdocs/docs/features/binary_formats/ubjson.md @@ -72,8 +72,9 @@ The library uses the following mapping from JSON values types to UBJSON types ac An array whose type marker is `Z` (null), `T` (true) or `F` (false) stores no payload at all, because the marker already is the value. Its declared count is therefore the only thing that decides how much memory the receiving side allocates, and a handful of bytes can describe billions of elements. `from_ubjson` rejects such an array with - [`out_of_range.408`](../../home/exceptions.md#jsonexceptionout_of_range408) when the count exceeds 1,048,576, and - `to_ubjson` writes longer arrays of these types without the annotation, so any value it produces can be read back. + [`out_of_range.408`](../../home/exceptions.md#jsonexceptionout_of_range408) when the count exceeds 1,048,576 + (`1 << 20`), and `to_ubjson` writes longer arrays of these types without the annotation, so any value it produces + can be read back. !!! info "Binary values" diff --git a/docs/mkdocs/docs/home/exceptions.md b/docs/mkdocs/docs/home/exceptions.md index 44a01df40..d80e00549 100644 --- a/docs/mkdocs/docs/home/exceptions.md +++ b/docs/mkdocs/docs/home/exceptions.md @@ -869,8 +869,8 @@ the size following `#` for [UBJSON](../features/binary_formats/ubjson.md)/[BJDat or the encoded length for [CBOR](../features/binary_formats/cbor.md). The exception is also thrown for a [UBJSON](../features/binary_formats/ubjson.md) array of a type that is encoded by its -marker alone (`Z`, `T` or `F`) whose declared count exceeds 1,048,576. Such an array has no payload, so its count alone -decides how much memory is allocated, and a handful of bytes would otherwise describe billions of values. +marker alone (`Z`, `T` or `F`) whose declared count exceeds 1,048,576 (`1 << 20`). Such an array has no payload, so its +count alone decides how much memory is allocated, and a handful of bytes would otherwise describe billions of values. [`to_ubjson`](../api/basic_json/to_ubjson.md) writes longer arrays of these types without the size and type annotation, so any value it produces can still be read back.