From 7e41e303d3cccd6b982e69057f4c112f7817d80b Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 16 Oct 2018 11:04:18 +0800 Subject: [PATCH] Closes #211 -- handle missing input consistently --- R/fromJSON.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/fromJSON.R b/R/fromJSON.R index 768bed92..6185be8f 100644 --- a/R/fromJSON.R +++ b/R/fromJSON.R @@ -77,6 +77,8 @@ fromJSON <- function(txt, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, simplifyMatrix = simplifyVector, flatten = FALSE, ...) { + # empty JSON -> empty data.frame + if (is.na(txt) || is.null(txt)) return(data.frame(NULL)) # check type if (!is.character(txt) && !inherits(txt, "connection")) { stop("Argument 'txt' must be a JSON string, URL or file.")