Files
json/single_include/nlohmann
Niels Lohmann 23aa069e63 Support any-rank C arrays in from_json, not just rank 1-4
from_json() for C arrays had four hand-unrolled overloads (rank 1-4,
added incrementally in #4262), each with its own nested loops. to_json()
already handles any rank recursively, so a rank-5+ C array could be
serialized but not read back with get_to()/get<>().

Replace the four overloads with one from_json() SFINAE-constrained on
get<remove_all_extents<T>::type>() existing, forwarding to a pair of
mutually recursive from_json_c_array_element() helpers: one assigns a
non-array element via get<T>(), the other loops over a array element and
recurses one dimension at a time. Each dimension still goes through at(),
so type_error.304/out_of_range.401 stay unchanged; ranks 1-4 keep their
existing behavior and semantics.

Adds rank-5 round-trip and mismatched-shape tests to unit-conversions.cpp.

Public API: additive only (rank 5+ C arrays become readable).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

#5708 item 1
2026-09-30 18:00:16 +02:00
..