tests/testthat/test-serializeJSON-datasets.R

#test serializeJSON 

context("Serializing Datasets")

# Note about numeric precision
# In the unit tests we use digits=10. Lowever values will result in problems for some datasets
test_that("Serializing datasets", {
  library(datasets);
  lapply(as.list(ls("package:datasets")), function(x){
    mycall <- call("expect_that", 
      call("unserializeJSON", call("serializeJSON", as.name(x), digits=10)),
      call("equals", as.name(x))
    );
    eval(mycall)
  });
});

Try the jsonlite package in your browser

Any scripts or data that you put into this service are public.

jsonlite documentation built on July 9, 2023, 6:11 p.m.