R/asJSON.function.R

setMethod("asJSON", "function", function(x, collapse = TRUE, fun = c("source", "list"), ...) {
  # validate
  fun <- match.arg(fun)

  if (fun == "source") {
    return(asJSON(deparse(x), ...))
  } else {
    return(asJSON(as.list(x), ...))
  }
})

Try the jsonlite package in your browser

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

jsonlite documentation built on April 4, 2025, 5:24 a.m.