shiny icon indicating copy to clipboard operation
shiny copied to clipboard

jsonlite warning with shiny 1.4.0

Open stla opened this issue 4 years ago • 12 comments

Hello,

Consider this app:

library(shiny)
library(ggplot2)

ui <- fluidPage(
  radioButtons("type", "Type of plot", choices = c("density", "boxplot")),
  plotOutput("plot")
)

server <- function(input, output){
  output[["plot"]] <- renderPlot({
    if(input$type == "density"){
      ggplot(iris, aes(Sepal.Length)) + geom_density()
    }else{
      ggplot(iris, aes(x = "", y = Sepal.Length)) + geom_boxplot()
    }
  })
}

shinyApp(ui, server)

When you select the radio button "boxplot", this message appears in the R console:

Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.

It is caused by x = "" in the aes. If I remove this argument, there's no warning anymore.

This message didn't appear with shiny < 1.4.0.

stla avatar Oct 18 '19 14:10 stla