mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-11 16:08:19 -05:00
Switch from RJSONIO to jsonlite
This commit is contained in:
@@ -65,7 +65,7 @@ Imports:
|
||||
utils,
|
||||
httpuv (>= 1.3.2),
|
||||
mime (>= 0.1.3),
|
||||
RJSONIO,
|
||||
jsonlite (>= 0.9.14),
|
||||
xtable,
|
||||
digest,
|
||||
htmltools (>= 0.2.6),
|
||||
|
||||
@@ -196,4 +196,3 @@ import(htmltools)
|
||||
import(httpuv)
|
||||
import(mime)
|
||||
import(xtable)
|
||||
importFrom(RJSONIO,fromJSON)
|
||||
|
||||
@@ -245,7 +245,7 @@ decodeMessage <- function(data) {
|
||||
if (readInt(1) != 0x01020202L) {
|
||||
# use native encoding for the message
|
||||
nativeData <- iconv(rawToChar(data), 'UTF-8')
|
||||
return(fromJSON(nativeData, asText=TRUE, simplify=FALSE))
|
||||
return(jsonlite::fromJSON(nativeData, simplifyVector=FALSE))
|
||||
}
|
||||
|
||||
i <- 5
|
||||
|
||||
@@ -18,7 +18,6 @@ NULL
|
||||
#' @aliases shiny
|
||||
#' @docType package
|
||||
#' @import htmltools httpuv xtable digest R6 mime
|
||||
#' @importFrom RJSONIO fromJSON
|
||||
NULL
|
||||
|
||||
|
||||
@@ -80,7 +79,8 @@ createUniqueId <- function(bytes, prefix = "", suffix = "") {
|
||||
}
|
||||
|
||||
toJSON <- function(x, ..., digits = getOption("shiny.json.digits", 16)) {
|
||||
RJSONIO::toJSON(x, digits = digits, ...)
|
||||
jsonlite::toJSON(x, dataframe = "columns", null = "null", na = "null",
|
||||
auto_unbox = TRUE, digits = digits, use_signif = TRUE, ...)
|
||||
}
|
||||
|
||||
# Call the workerId func with no args to get the worker id, and with an arg to
|
||||
@@ -301,7 +301,7 @@ ShinySession <- R6Class(
|
||||
|
||||
if (!is.null(websocket$request$HTTP_SHINY_SERVER_CREDENTIALS)) {
|
||||
try({
|
||||
creds <- fromJSON(websocket$request$HTTP_SHINY_SERVER_CREDENTIALS)
|
||||
creds <- jsonlite::fromJSON(websocket$request$HTTP_SHINY_SERVER_CREDENTIALS)
|
||||
session$user <<- creds$user
|
||||
session$groups <<- creds$groups
|
||||
}, silent=FALSE)
|
||||
|
||||
@@ -452,7 +452,7 @@ updateSelectizeInput <- function(session, inputId, label = NULL, choices = NULL,
|
||||
selectizeJSON <- function(data, req) {
|
||||
query <- parseQueryString(req$QUERY_STRING)
|
||||
# extract the query variables, conjunction (and/or), search string, maximum options
|
||||
var <- unlist(fromJSON(query$field, asText = TRUE))
|
||||
var <- unlist(jsonlite::fromJSON(query$field))
|
||||
cjn <- if (query$conju == 'and') all else any
|
||||
# all keywords in lower-case, for case-insensitive matching
|
||||
key <- unique(strsplit(tolower(query$query), '\\s+')[[1]])
|
||||
|
||||
@@ -691,11 +691,6 @@ dataTablesJSON <- function(data, req) {
|
||||
for (j in seq_len(ncol(fdata))[k]) fdata[, j] <- htmlEscape(fdata[, j])
|
||||
}
|
||||
}
|
||||
# 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 (length(fdata) && all(dim(fdata) == 1)) fdata <- list(list(fdata[1, 1]))
|
||||
|
||||
res <- toJSON(list(
|
||||
draw = as.integer(q$draw),
|
||||
|
||||
@@ -15,7 +15,7 @@ test_that("Date converts to date", {
|
||||
x <- "2013/01/01"
|
||||
class(x) <- "shiny.date"
|
||||
handler <- inputHandlers$get('shiny.date')
|
||||
expect_identical(
|
||||
expect_identical(
|
||||
handler(x), as.Date(unclass(x))
|
||||
)
|
||||
})
|
||||
@@ -24,7 +24,7 @@ test_that("List of dates converts to vector", {
|
||||
x <- list("2013/01/01", "2014/01/01")
|
||||
class(x) <- "shiny.date"
|
||||
handler <- inputHandlers$get('shiny.date')
|
||||
expect_identical(
|
||||
expect_identical(
|
||||
handler(x), as.Date(unlist(x))
|
||||
)
|
||||
})
|
||||
@@ -41,7 +41,7 @@ test_that("Matrix converts list of lists to matrix", {
|
||||
test_that("Nulls are not converted to NAs in parsing", {
|
||||
msg <- charToRaw("{\"method\":\"init\",\"data\":{\"obs\":500,\"nullObs\":null}}")
|
||||
expect_identical(
|
||||
decodeMessage(msg),
|
||||
list(method="init", data=list(obs=500, nullObs=NULL))
|
||||
decodeMessage(msg),
|
||||
list(method="init", data=list(obs=500L, nullObs=NULL))
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user