The string is judged as JSON text only: a file path or URL is never read.
Arguments
- input_string
A character string to be checked for JSON format. A
character vector with more than one element is treated as the lines of
one text. Windows (CRLF) line endings are accepted.
Value
A single TRUE if the input is valid JSON, otherwise FALSE.
Non-character input, NA elements and empty or blank strings return
FALSE.
Author
Ulrich Matter umatter@protonmail.com
Examples
is_json('{"name": "John", "age": 30}')
#> [1] TRUE
# TRUE
is_json('{"name": "John", age: 30}')
#> [1] FALSE
# FALSE
is_json('')
#> [1] FALSE
# FALSE