tests/testthat/flatten.R

context("flatten")

test_that("flattening", {
  x <- list(test = data.frame(foo=1:3))
  x$test$bar <- data.frame(x=5:3, y=7:9)
  expect_that(x, equals(fromJSON(toJSON(x), flatten = FALSE)));
  expect_that(names(fromJSON(toJSON(x), flatten = TRUE)$test), equals(c("foo", "bar.x", "bar.y")))
});

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.