Question: This question is about a generic mechanism for converting any collection of non-cyclical homogeneous or heterogeneous data structures into a dataframe. This can be particularly useful when dealing with the ingestion of many JSON documents or with a large JSON document that is an array of dictionaries.

There are several SO questions that deal with manipulating deeply nested JSON structures and turning them into dataframes using functionality such as `plyr`, `lapply`, etc. All the questions and answers I have found are about specific cases as opposed to offering a general approach for dealing with collections of complex JSON data structures. 

In Python and Ruby I've been well-served by implementing a generic data structure flattening utility that uses the path to a leaf node in a data structure as the name of the value at that node in the flattened data structure. For example, the value `my_data[['x']][[2]][['y']]` would appear as `result[['x.2.y']]`. 

If one has a collection of these data structures that may not be entirely homogeneous the key to doing a successful flattening to a dataframe would be to discover the names of all possible dataframe columns, e.g., by taking the union of all keys/names of the values in the individually flattened data structures.

This seems like a common pattern and so I'm wondering whether someone has already built this for R. If not, I'll build it but, given R's unique promise-based data structures, I'd appreciate advice on an implementation approach that minimizes heap thrashing.

Answer: 
The `jsonlite` package is a fork of `RJSONIO` specifically designed to make conversion between JSON and data frames easier. You don't provide any example `json` data, but I think this might be what you are looking for. Have a look at this [blog post](https://www.opencpu.org/posts/jsonlite-a-smarter-json-encoder/) or [the vignette](http://cran.r-project.org/web/packages/jsonlite/vignettes/json-mapping.pdf).
I'm now a big fan of simply:

```
library(jsonlite)
library(tidyverse)

fromJSON("file_path.json") %>% 
unlist() %>% 
enframe()

```

And then potentially, depending on your data, piping that into

```
%>%
pivot_wider()

```

Once it's in a flat table shape, there are a load of tools in tidyverse and other R libraries more generally for wrangling things around and e.g., dealing with columns with similar prefixes (which will result from the above pipeline as the parent name of the children within a nested json chunk will be prefixed to the child's name).