R/json.R

Defines functions export_map

Documented in export_map

#' Export a map to a JSON file
#'
#' @param map The function map.
#' @param file The file or connection to write to.
#' @param pretty Whether to pretty print the JSON file.
#'
#' @export
#' @importFrom jsonlite toJSON unbox

export_map <- function(map, file, pretty = TRUE) {
  data <- list(
    package = unbox(map$package),
    exports = map$exports,
    functions = node_df(map),
    calls = edge_df(map)
  )

  cat(toJSON(data, pretty = pretty), file = file)
}
MangoTheCat/functionMap documentation built on May 7, 2019, 2:10 p.m.