This function and its methods allows the caller to verify if the JSON content is strictly valid. Even if the content is invalid, the parser may still be able to make sense of it or at least get it partially correct and yield a result. So this function allows the caller to verify that the input is legitimate and not just rely on the parser not failing.

isValidJSON(content, asText = inherits(content, "AsIs"), ...)

Arguments

content

the JSON input either as a string, the name of a file or URL, or a connection object.

asText

a logical value that specifies whether the value in content is actually the JSON content or the name of a file

...

additional parameters for the methods

Value

A logical value indicating whether the content is valid JSON (TRUE) or invalid (FALSE).

References

libjson

Author

Duncan Temple Lang duncan@wald.ucdavis.edu \ Yaoxiang Li liyaoxiang@outlook.com

See also

Examples

   isValidJSON(I('{"foo" : "bar"}'))
#> [1] TRUE

   isValidJSON(I('{foo : "bar"}'))
#> [1] FALSE
   isValidJSON('{foo : "bar"}', TRUE)
#> [1] FALSE