Skip to content

Commit

Permalink
Disable auto_unbox inside matrix or array
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Oct 3, 2014
1 parent c041232 commit 2a7ba7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions R/asJSON.array.R
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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, ...)

Expand Down

0 comments on commit 2a7ba7b

Please sign in to comment.