Closed mstackhouse closed 11 months ago
con <- url(
"https://github.com/cdisc-org/DataExchange-DatasetJson/raw/master/examples/sdtm/ti.json",
method = "libcurl"
)
x <- readLines(con, warn=FALSE)
close(con)
jsonlite::fromJSON(x)
For a local file for testing:
con <- url(paste0("file://", normalizePath(test_path("testdata", "ta.json"))))
This is url detection from {readr}:
https://github.com/tidyverse/readr/blob/b3d09122074143987754a83ccb6eec730a20a37e/R/source.R#L196
is_url <- function(path) {
grepl("^((http|ftp)s?|sftp)://", path)
}
Could just add in additionally for local files:
^((http|ftp)s?|sftp|file):\/\/
Feature Idea
Replicate the function of haven, where
haven::read_xpt()
can pull directly from a URL like GitHub raw filesRelevant Input
URL
Relevant Output
Dataframe
Reproducible Example/Pseudo Code