From 2a7ba7bb531f3d538a70ac145c89e8fdb382f96d Mon Sep 17 00:00:00 2001 From: Jeroen Ooms <jeroenooms@gmail.com> Date: Fri, 3 Oct 2014 08:54:50 +0200 Subject: [PATCH] Disable auto_unbox inside matrix or array --- NEWS | 3 +++ R/asJSON.array.R | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2bc63fe..a77723d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +0.9.13 + - Prevent auto unboxing within a matrix + 0.9.12 - New JSON parser based on yajl. Some changes: * smaller and faster than libjson diff --git a/R/asJSON.array.R b/R/asJSON.array.R index a5e5c4b..5809e12 100644 --- a/R/asJSON.array.R +++ b/R/asJSON.array.R @@ -1,5 +1,5 @@ setMethod("asJSON", "array", function(x, collapse = TRUE, na = NULL, oldna = NULL, - matrix = c("rowmajor", "columnmajor"), ...) { + matrix = c("rowmajor", "columnmajor"), auto_unbox = FALSE, ...) { #validate matrix <- match.arg(matrix); @@ -9,9 +9,9 @@ setMethod("asJSON", "array", function(x, collapse = TRUE, na = NULL, oldna = NUL na <- oldna; } - # row based json # if collapse == FALSE, then this matrix is nested inside a data frame, # and therefore row major is required to match dimensions + # dont pass auto_unbox (never unbox within matrix) margin <- ifelse(identical(matrix, "columnmajor") && isTRUE(collapse), length(dim(x)), 1); tmp <- apply(x, margin, asJSON, matrix = matrix, na = na, ...)