I had to run a few tests to be sure, but the ability to read unnamed root arrays seems to be limited to json_foreach.
Given a sample named JSON array of literals and a few test commands:
Use "{"array":["a","b","c","d"]}"
json "ON" "current"
json_select_array "array" -1 ","
json_select_array "array" 1
json_foreach "array"
json_foreach_end
I get (respectively):
a,b,c,d ##_ json_select_array "array" -1 ","
a ##_ json_select_array "array" 1
4 ##_ json_foreach "array" ---> (number of literals in array)
The same (array name removed) commands on the unnamed variant:
Use "["a","b","c","d"]"
json "ON" "current"
json_select_array "" -1 ","
json_select_array "" 1
json_foreach ""
json_foreach_end
now returns
<empty> ##_ json_select_array "" -1 ","
<empty> ##_ json_select_array "" 1
4 ##_ json_foreach "" ---> (also number of literals in array)
So it would seem that
only json_foreach "" has support for unnamed root arrays, unlike json_select_array.
@Florian can I bother you again to chime in an opinion on this, please? ![]()