R/utils-json-reading.R

Defines functions tsg_json

## excel reading function utility to reduce code reproduction

tsg_json <- function(temp_f) {
  z <- tryCatch(
    {
      jsonlite::fromJSON(temp_f,
        flatten = FALSE
      )
    },
    error = function(cond) {
      return(NA)
    }
  )

  ## due to `grants` being nested one level down
  if (!is.data.frame(z) && is.data.frame(z[[1]])) {
    z <- tibble::as_tibble(z[[1]])
  }

  z
}

Try the threesixtygiving package in your browser

Any scripts or data that you put into this service are public.

threesixtygiving documentation built on Dec. 2, 2020, 5:05 p.m.