`fromJSON()` not working for R 4.3
kellijohnson-NOAA opened this issue · 1 comments
I am using the devel version of R on a Windows machine and jsonlite::fromJSON()
thinks that the text string, which is a valid URL, is a file path and the functions below end up returning empty data frames and warning messages that the pulls cannot be completed as requested. I have written the following work around if the behaviour is not corrected before 4.3 is released. Regardless, we could implement the following function because it appears to be more robust than relying on just jsonlite::fromJSON()
get_json <- function(url) {
out <- httr::GET(url) %>%
httr::content(as = "text", encoding = "UTF-8") %>%
jsonlite::fromJSON()
if (!(is.data.frame(out) && NROW(out) > 0)) {
stop(glue::glue("No data returned by the warehouse using {url}"))
}
return(out)
}
Line 193 in 3d68e95
Line 236 in 5a97b04
Line 114 in 5a97b04
Line 161 in 5a97b04
Line 63 in 5a97b04
Line 149 in 5a97b04
Line 186 in 5a97b04
nwfscSurvey/R/pull_biological_samples.R
Line 131 in 5a97b04
Line 152 in b2d19d3
Line 197 in b2d19d3
Line 104 in b2d19d3
Closed with c4cf148