Revert switch to jsonlite

This reverts commits deffc90, ab4dc64, and 0755579, returning to RJSONIO.
The purpose of this is to prepare for a maintenance release for 0.11
without the switch to jsonlite, to reduce the risk of new bugs.
This commit is contained in:
Winston Chang
2015-02-06 10:47:42 -06:00
parent b74e93f3a4
commit 040ae293fb
11 changed files with 26 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
writeReactLog <- function(file=stdout()) {
cat(toJSON(.graphStack$as_list(), pretty=TRUE), file=file)
cat(RJSONIO::toJSON(.graphStack$as_list(), pretty=TRUE), file=file)
}
#' Reactive Log Visualizer

View File

@@ -9,7 +9,7 @@ inputHandlers <- Map$new()
#'
#' Adds an input handler for data of this type. When called, Shiny will use the
#' function provided to refine the data passed back from the client (after being
#' deserialized by jsonlite) before making it available in the \code{input}
#' deserialized by RJSONIO) before making it available in the \code{input}
#' variable of the \code{server.R} file.
#'
#' This function will register the handler for the duration of the R process
@@ -31,7 +31,7 @@ inputHandlers <- Map$new()
#' parameters:
#' \enumerate{
#' \item{The value of this input as provided by the client, deserialized
#' using jsonlite.}
#' using RJSONIO.}
#' \item{The \code{shinysession} in which the input exists.}
#' \item{The name of the input.}
#' }
@@ -64,7 +64,7 @@ registerInputHandler <- function(type, fun, force=FALSE){
#' Deregister an Input Handler
#'
#' Removes an Input Handler. Rather than using the previously specified handler
#' for data of this type, the default jsonlite serialization will be used.
#' for data of this type, the default RJSONIO serialization will be used.
#'
#' @param type The type for which handlers should be removed.
#' @return The handler previously associated with this \code{type}, if one
@@ -245,7 +245,7 @@ decodeMessage <- function(data) {
if (readInt(1) != 0x01020202L) {
# use native encoding for the message
nativeData <- iconv(rawToChar(data), 'UTF-8')
return(jsonlite::fromJSON(nativeData, simplifyVector=FALSE))
return(fromJSON(nativeData, asText=TRUE, simplify=FALSE))
}
i <- 5

View File

@@ -18,6 +18,7 @@ NULL
#' @aliases shiny
#' @docType package
#' @import htmltools httpuv xtable digest R6 mime
#' @importFrom RJSONIO fromJSON
NULL
@@ -79,9 +80,7 @@ createUniqueId <- function(bytes, prefix = "", suffix = "") {
}
toJSON <- function(x, ..., digits = getOption("shiny.json.digits", 16)) {
jsonlite::toJSON(x, dataframe = "columns", null = "null", na = "null",
auto_unbox = TRUE, digits = digits, use_signif = TRUE,
force = TRUE, ...)
RJSONIO::toJSON(x, digits = digits, ...)
}
# Call the workerId func with no args to get the worker id, and with an arg to
@@ -200,7 +199,7 @@ workerId <- local({
#' \item{sendCustomMessage(type, message)}{
#' Sends a custom message to the web page. \code{type} must be a
#' single-element character vector giving the type of message, while
#' \code{message} can be any jsonlite-encodable value. Custom messages
#' \code{message} can be any RJSONIO-encodable value. Custom messages
#' have no meaning to Shiny itself; they are used soley to convey information
#' to custom JavaScript logic in the browser. You can do this by adding
#' JavaScript code to the browser that calls
@@ -302,7 +301,7 @@ ShinySession <- R6Class(
if (!is.null(websocket$request$HTTP_SHINY_SERVER_CREDENTIALS)) {
try({
creds <- jsonlite::fromJSON(websocket$request$HTTP_SHINY_SERVER_CREDENTIALS)
creds <- fromJSON(websocket$request$HTTP_SHINY_SERVER_CREDENTIALS)
session$user <<- creds$user
session$groups <<- creds$groups
}, silent=FALSE)

View File

@@ -453,7 +453,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(jsonlite::fromJSON(query$field))
var <- unlist(fromJSON(query$field, asText = TRUE))
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]])

View File

@@ -705,6 +705,11 @@ 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),