Provide a way to iterate through json arrays/objects
Currently the approach to iterate over a json array is to
string(JSON LENGTH)
math(length-1)
foreach(index RANGE length-1)
string(JSON GET "index")
...
endforeach()
which is terribly inefficient since string(JSON) inside the foreach() has to reparse the whole json again over and over.
Would it be possible to have a
foreach(json_elem IN JSON json_var)
which is capable to iterate over each object/index?
I would also advocate for providing a cmake variable string(JSON) API instead of the string based one since the current approach clutters --trace-exapnd output a lot.