test_that("Test JSON file", {
data.w <- list(test = 1)
json <- JSONFile$new(tempfile(fileext=".json"))
json$write(data.w)
data.r <- json$read()
expect_equal(data.r$test, data.w$test)
})
test_that("Test write null", {
data.w <- list(test = NULL)
tmp.json <- tempfile(fileext=".json")
json <- JSONFile$new(tmp.json)
json$write(data.w)
text <- TextFile$new(tmp.json)
data.r <- text$read()
expect_equal(data.r, '{"test":null}')
})
test_that("Test encrypted json", {
data.w <- list(test = 1)
tmp.json <- tempfile(fileext=".json")
ejson <- EJSONFile$new(tmp.json, "abc688b260b4681236b8a4df8c1d96ee")
ejson$write(data.w, encrypt=TRUE)
json <- JSONFile$new(tmp.json)
data.r <- json$read()
expect_true("content" %in% names(data.r))
expect_true("iv" %in% names(data.r))
data.r <- ejson$read()
expect_equal(data.r$test, data.w$test)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.