16  16. Using JSON in R with jsonlite package

16.1 jsonlite vignettes

The jsonlite R pacakge is used to read JSON files into R. The following is the link to the CRAN webpage for the jsonlite package. See the vignettes and reference manual linked there.

jsonlite: A Simple and Robust JSON Parser and Generator for R

Below, I copied the links to some of the vignettes from that page. However, it’s best to check the official CRAN page in case there are modifications or if there are new vignettes added there (this page was compiled in Jan 2025).

16.2 toJSON - create JSON from an R object

16.2.1 pretty argument and prettify function

16.2.2 use writeLines to write the JSON to a file

16.2.3 toJSON(SOME_R_OBJECT , auto_unbox=TRUE)

readLines and writeLines

16.3 fromJSON - create an R object from JSON

16.4 Working with nested dataframes

16.4.1 tidyr - unnest , expand , crossing , nesting (TODO get exmaples from LLMs)