Files
cmake/Help/release/dev/string-json-array-split.rst
Daksh Mamodiya 7cca8540ca string(JSON): Add ARRAY_SPLIT mode for linear array iteration
Iterating a JSON array with GET re-parses the entire string on every
call, so walking N elements is O(N^2).  ARRAY_SPLIT parses the array
once and returns its elements as a CMake list, letting each element be
queried individually in linear total time.

Each element is re-serialized as compact JSON and encoded to survive
CMake list parsing: '[' and ']' inside strings are emitted as \u005B
and \u005D, and ';' is escaped as '\;'.  Every element therefore stays
valid, re-queryable JSON.

Fixes: #27985
2026-08-07 17:45:50 +02:00

8 lines
297 B
ReStructuredText

string-json-array-split
-----------------------
* The :command:`string(JSON)` command gained an ``ARRAY_SPLIT`` mode that
splits a JSON array into a list of its elements with a single parse,
enabling linear-time array iteration instead of re-parsing the whole
JSON string for each element.