tests/testthat/test-delete.R

x <- json2(c(NA, '{"a":11,"b":{"x":12}}'))

test_that("delete works", {
  expect_equal(
    json_delete(x, "$.a"),
    json2(c(NA, '{"b":{"x":12}}'))
  )

  expect_equal(
    json_delete(x, "$.not_there"),
    x
  )
})

Try the jsontools package in your browser

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

jsontools documentation built on March 22, 2021, 5:06 p.m.