Skip to content

Document parameters bigint_as_char and json_verbatim #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions R/apply_by_pages.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ apply_by_pages <- function(x, FUN, pagesize, verbose, ...){
npages <- nr %/% pagesize;
lastpage <- nr %% pagesize;

`[.json` <- function(x, i) {
structure(NextMethod("["), class = c("json", "character"))
}

out <- as.list(rep(NA, npages + as.logical(lastpage)))
for(i in seq_len(npages)){
from <- pagesize * (i-1) + 1;
Expand Down
4 changes: 3 additions & 1 deletion R/fromJSON.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#' @param digits max number of decimal digits to print for numeric values. Use \code{I()} to specify significant digits. Use \code{NA} for max precision.
#' @param force unclass/skip objects of classes with no defined JSON mapping
#' @param pretty adds indentation whitespace to JSON output. Can be TRUE/FALSE or a number specifying the number of spaces to indent. See \code{\link{prettify}}
#' @param json_verbatim do not JSON encode a json character (i.e. a character coming from `toJSON()`) again but leave it as it is
#' @param bigint_as_char read big integers as character
#' @param ... arguments passed on to class specific \code{print} methods
#' @references Jeroen Ooms (2014). The \code{jsonlite} Package: A Practical and Consistent Mapping Between JSON Data and \R{} Objects. \emph{arXiv:1403.2805}. \url{https://arxiv.org/abs/1403.2805}
#' @examples # Stringify some data
Expand Down Expand Up @@ -75,7 +77,7 @@
#' identical(data3, flatten(data2))
#' }
fromJSON <- function(txt, simplifyVector = TRUE, simplifyDataFrame = simplifyVector,
simplifyMatrix = simplifyVector, flatten = FALSE, ...) {
simplifyMatrix = simplifyVector, flatten = FALSE, bigint_as_char = FALSE, ...) {

# check type
if (!is.character(txt) && !inherits(txt, "connection")) {
Expand Down
2 changes: 1 addition & 1 deletion R/toJSON.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ toJSON <- function(x, dataframe = c("rows", "columns", "values"), matrix = c("ro
Date = c("ISO8601", "epoch"), POSIXt = c("string", "ISO8601", "epoch", "mongo"),
factor = c("string", "integer"), complex = c("string", "list"), raw = c("base64", "hex", "mongo"),
null = c("list", "null"), na = c("null", "string"), auto_unbox = FALSE, digits = 4,
pretty = FALSE, force = FALSE, ...) {
pretty = FALSE, force = FALSE, json_verbatim = FALSE, ...) {

# validate args
dataframe <- match.arg(dataframe)
Expand Down
41 changes: 31 additions & 10 deletions man/fromJSON.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/stream_in.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.