fixes #429, which is yet yet another WAT of RJSONIO

perhaps we really should consider switching to jsonlite...
This commit is contained in:
Yihui Xie
2014-05-17 00:43:13 -05:00
parent b00fbda1ae
commit 79c92f1f8e
2 changed files with 7 additions and 0 deletions

3
NEWS
View File

@@ -27,6 +27,9 @@ shiny 0.9.1.9XXX
* `sliderInput` and `selectizeInput`/`selectInput` now use a standard horizontal
size instead of filling up all available horizontal space.
* Fixed a bug of renderDataTable() when the data object only has 1 row and 1
column. (Thanks, ZJ Dai, #429)
shiny 0.9.1
--------------------------------------------------------------------------------

View File

@@ -606,7 +606,11 @@ dataTablesJSON <- function(data, req) {
fdata <- data[i, , drop = FALSE] # filtered data
} else fdata <- data
fdata <- unname(as.matrix(fdata))
# WAT: toJSON(list(x = matrix(nrow = 0, ncol = 1))) => {"x": } (#299)
if (nrow(fdata) == 0) fdata <- list()
# WAT: toJSON(list(x = matrix(1:2))) => {x: [ [1], [2] ]}, however,
# toJSON(list(x = matrix(1))) => {x: [ 1 ]} (loss of dimension, #429)
if (all(dim(fdata) == 1)) fdata <- list(list(fdata[1, 1]))
res <- toJSON(list(
sEcho = as.integer(sEcho),