Open
Description
ibrary(testthat)
.Random.seed <<- .ext.seed
test_that("parseJSON", {
txt <- "[true,false,null]"
bigint_as_char <- FALSE
expect_equal(jsonlite:::parseJSON(txt = txt, bigint_as_char = bigint_as_char), list(TRUE, FALSE, NA))
})
The problem with this test that for the given txt
jsonlite:::parseJSON
returns list(TRUE, FALSE, NULL)
. There is somewhere a conversion between NULL and NA. This is one of the feature of jsonlite, but I do not see where.
The same is here:
library(testthat)
.Random.seed <<- .ext.seed
test_that("parseJSON", {
txt <- "[1,2,\"NA\",\"NaN\",\"Inf\",\"-Inf\",3.14]"
bigint_as_char <- FALSE
expect_equal(jsonlite:::parseJSON(txt = txt, bigint_as_char = bigint_as_char), list(1L, 2L, NA, NaN, Inf, -Inf, 3.14))
})
In this case it returns:
str(jsonlite:::parseJSON(txt = txt, bigint_as_char = F))
List of 7
$ : int 1
$ : int 2
$ : chr "NA"
$ : chr "NaN"
$ : chr "Inf"
$ : chr "-Inf"
$ : num 3.14