leeruns
(K Runyon)
1
Simple usage question here. If I want to count the size of a json array
- read json file
- count number of entryies in top level array
- save number of entries as a variable
file(read JSON input.json input)
string(JSON len LENGTH ${input} 0 ARRAY_MEMBERS)
set( length_of_array ${len})
ben.boeckel
(Ben Boeckel (Kitware))
2
I think this would work better:
file(READ "input.json" input)
string(JSON length_of_array LENGTH "${input}" "")
though I’m not 100% sure on how to reference the top-level object/array (that last empty string argument).