foreach for rscript + test (completes json-array support, except documentation)