tests/testthat/test-as_json.R

context("as_json")

test_that("json class set", {
  
  js <- "{x:1}"  ## Invalid
  # expect_error( as.json(js), "Invalid JSON" )
  
  js <- '{"x":1}'
  js <- as.json(js)
  expect_equal( attr(js, "class"), "json" )
  
  js <- '{"x":[1,2,3]}'
  js <- pretty_json(js)
  expect_equal( attr(js, "class"), "json" )
})

Try the jsonify package in your browser

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

jsonify documentation built on Nov. 10, 2022, 5:34 p.m.