R/emld-methods.R

Defines functions print.emld

#' @importFrom yaml as.yaml
#' @importFrom jsonlite toJSON
#' @export
print.emld <- function(x, ...){
  x[["@context"]] <- NULL # context just adds clutter to display
  x[["@type"]] <- NULL
  style <- getOption("emld_print", "yaml")
  #cat("EML as an emld object:\n\n\n")
  switch(style,
         "yaml" = cat(yaml::as.yaml(x)),
         "json" = cat(jsonlite::toJSON(x, auto_unbox = TRUE, pretty = TRUE))
  )
}
cboettig/emljson documentation built on Oct. 27, 2020, 1:27 a.m.