Skip to content

Help: Fix string(JSON ... LENGTH ...) signature

The list of indices and/or member names is optional, i.e., can be empty. For example, string(JSON foo LENGTH "[0,0,0]") sets foo to 3.

# Documented:
string(JSON foo LENGTH "{ \"a\": {}, \"b\": [1, 2, 3, 4] }" "b")
string(JSON bar LENGTH "[[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]]" 1)
message(STATUS "foo = ${foo} (expect 4), bar = ${bar} (expect 2)")

# Undocumented:
string(JSON foo LENGTH "{ \"a\": {}, \"b\": [1, 2, 3, 4] }")
string(JSON bar LENGTH "[[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]]")
message(STATUS "foo = ${foo} (expect 2), bar = ${bar} (expect 4)")

Backport: release

Edited by Brad King

Merge request reports