Learn R Programming

jsontools (version 0.1.0)

json_is_valid: Assert vector is valid JSON.

Description

Uses jsonlite::validate() under the hood.

Usage

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

Run this code
# NOT RUN {
json_is_valid("[1, 2]")
json_is_valid("[1, 2")

json_assert_valid("[1, 2]")
# }
# NOT RUN {
json_assert_valid("[1, 2")
# }

Run the code above in your browser using DataLab