Reading in a folder of json files into R

Hello,

I'm new to R. How do I read in a folder that contains many json files into R? I want the files to have a list format in R. I can read in individual json files using the rjson package, but I don't know how to do a whole folder of them. For example, I can do this:

my_list <- fromJSON(file = "my_file_name.json")

and it produces a list I can work with. Thank you!!

I would use a map function.
collate a list of files to process (i.e. their paths as character vector), and iterate the fromJson function over that list of paths.

so something like list.files() hold that in an object (mylistoffiles), to make a list to process and then

purrr::map(mylistoffiles,
           ~fromJson(file=.))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.