Skip to content

Commit

Permalink
Handle invalid JSON from API; fixes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
petrbouchal committed Aug 21, 2023
1 parent e0aa7c1 commit 2092fde
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ RdMacros:
Encoding: UTF-8
Language: en
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.1.9000
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# czso (development version)

* fix (hopefully temporary) to handle invalid JSON from e.g. https://vdb.czso.cz/pll/eweb/package_show?id=150196 (newlines, issue reported as #52)

# czso 0.3.10

* update Roxygen2 version and rebuild documentation to handle CRAN validation of HTML manual
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_clean <- stringi::stri_replace_all_regex(mtdt_c, "\\n", "")
mtdt <- jsonlite::fromJSON(mtdt_clean)[["result"]]
if(is.null(mtdt)) cli::cli_abort("No dataset found with this ID.")
return(mtdt)
}
Expand Down

0 comments on commit 2092fde

Please sign in to comment.