json_assert_valid: Assert vector is valid JSON.

Description Usage Arguments Value Examples

View source: R/json.R

Description

Uses jsonlite::validate() under the hood.

Usage

1
2
3
json_is_valid(x)

json_assert_valid(x, x_arg = "")

Arguments

x

A character vector.

x_arg

Argument name for x. Used in error message to inform the user about the location of the error.

Value

json_is_valid() returns a vector of TRUE and FALSE. json_assert_valid() either throws an error with information on the invalid elements or returns x invisibly

Examples

1
2
3
4
5
6
7
8
json_is_valid("[1, 2]")
json_is_valid("[1, 2")

json_assert_valid("[1, 2]")
## Not run: 
json_assert_valid("[1, 2")

## End(Not run)

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