Is test a vector?
Depending on the type of vector you could use map_* functions from the purrr package.
output <- map_chr(filenames, ~fromJSON(file = .x))
If the output from fromJSON is not a character, then you could use one of the other variants. There is map_dbl for class double, map_int for integers, map_lgl for logicals, map_dfr for dataframes/tibbles that you want binded by rows (i.e. binded like bind_rows or rbind) and map_dfc for dataframes/tibbles you want binded by column (i.e. binded by bind_cols or cbind).
If you are not sure of the output, you could simply use map in place of map_chr and it will return a list instead of a vector.