I have thousands of very small json
files in a directory.
Right now, I am using the following code to load them:
library(dplyr)
library(jsonlite)
library(purrr)
filelistjson <- list.files(DATA_DIRECTORY, full.names = TRUE, recursive = TRUE)
filelistjson %>% map(., ~fromJSON(file(.x)))
Unfortunately, this is extremely slow (I also tried with furrr::future_map
) I wonder if there is a better approach here. the individual files are barely 25KB
in size...
The files look look like the following, with a couple nested variables but nothing too complicated
{
"field1": "hello world",
"funny": "yes",
"date": "abc1234",
"field3": "hakuna matata",
"nestedvar":[
"http://www.stackoverflow.com",
"http://www.stackoverflow.com/funny"
],
"othernested":[
{
"one": "two",
"test": "hello"
}
]
}
Thanks!