tests/testthat/test-to_json_validate.R

context("validate")

test_that("validate works", {
  
  expect_true(validate_json('[]'))
  expect_true(validate_json('{}'))
  expect_true(validate_json('[{}]'))
  expect_true(validate_json('{"x":1}'))
  expect_true(validate_json('{"x":"a"}'))
  expect_true(validate_json('[{"x":1},{"y":[1,2,3,4]}]'))
  
  expect_false(validate_json(''))
  expect_false(validate_json('{[]}'))
  expect_false(validate_json('{"x"}'))
  expect_false(validate_json('{"x":1]'))
  expect_false(validate_json('[{"x":1},{"y":[1,2,3,4}]'))
})

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.