diff --git a/NEWS.md b/NEWS.md index c50ffd113..563c40def 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,8 @@ * The return value of `actionButton()`/`actionLink()` changed slightly: `label` and `icon` are wrapped in an additional HTML container element. This allows for: 1. `updateActionButton()`/`updateActionLink()` to distinguish between the `label` and `icon` when making updates and 2. spacing between `label` and `icon` to be more easily customized via CSS. +* The internal (not `jsonlite::`) implementation of `toJSON` now converts named vectors to named lists in order to avoid jsonlite's message when `keep_vec_names=TRUE`. + # shiny 1.11.1 This is a patch release primarily for addressing the bugs introduced in v1.11.0. diff --git a/R/shiny.R b/R/shiny.R index c5e1eadc1..c9788574b 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -38,7 +38,13 @@ toJSON <- function(x, ..., dataframe = "columns", null = "null", na = "null", # https://github.com/jeroen/jsonlite/commit/728efa9 digits = getOption("shiny.json.digits", I(16)), use_signif = is(digits, "AsIs"), force = TRUE, POSIXt = "ISO8601", UTC = TRUE, - rownames = FALSE, keep_vec_names = TRUE, strict_atomic = TRUE) { + rownames = FALSE, keep_vec_names = TRUE, strict_atomic = TRUE, fix_vec_names = TRUE) { + + # jsonlite complains about named _vectors_, so we'll force all + # named-vectors to be named-lists + if (fix_vec_names) { + x <- lapply(x, function(L) if (is.null(names(L))) L else as.list(L)) + } if (strict_atomic) { x <- I(x)