Skip to content

Commit

Permalink
handle invalid JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
petrbouchal committed Apr 2, 2024
1 parent 8fcb247 commit d9f6b06
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# czso (development version)

* fix documentation to avoid CRAN NOTEs
* handle invalid JSON in old CZSO API
* hard-deprecate old functions; they will be removed in the next version

# czso 0.3.10
Expand Down
3 changes: 2 additions & 1 deletion R/core.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ czso_get_dataset_metadata <- function(dataset_id) {
httr::user_agent(ua_string)) %>%
httr::stop_for_status() %>%
httr::content(as = "text")
mtdt <- jsonlite::fromJSON(mtdt_c)[["result"]]
mtdt_c_sanitised <- gsub("\\t", "\\s", mtdt_c)
mtdt <- jsonlite::fromJSON(mtdt_c_sanitised)[["result"]]
if(is.null(mtdt)) cli::cli_abort("No dataset found with this ID.")
return(mtdt)
}
Expand Down

0 comments on commit d9f6b06

Please sign in to comment.