Skip to content

Commit

Permalink
Fix for NULL strings introduced by jsonlite::fromJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansteffan committed Aug 27, 2024
1 parent 5909ef9 commit 8579a3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: peekbankr
Type: Package
Title: Accessing the Peekbank Database
Version: 0.1.1.9009
Version: 0.1.1.9010
Authors@R: c(
person("Mika", "Braginsky", email = "[email protected]", role = c("aut", "cre")),
person("Kyle", "MacDonald", email = "[email protected]", role = "aut"),
Expand Down
15 changes: 15 additions & 0 deletions R/peekbankr.R
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,21 @@ unpack_aux_data <- function(df) {

aux_cols <- lapply(col_names, \(col_name) {
sapply(aux_list, \(aux) {
# cursed way to make sure that there are no "NULL" strings left over
# from weird jsonlite::fromJSON behavior,
# check https://github.com/jeroen/jsonlite/issues/70 to see if there has been a fix by now
if(length(aux) == 1 &&
(is.na(aux) ||
is.null(aux[col_name]) ||
aux[col_name] == "NULL"
) || (
all(is.na(aux)) ||
all(is.null(aux[col_name]) ) ||
all(aux[col_name] == "NULL")
)
){
return(NA)
}
aux[col_name]
})
}) |>
Expand Down

0 comments on commit 8579a3e

Please sign in to comment.