Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

isValidJSON

Test if JSON content is valid


Description

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.

Usage

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).

Author(s)

Duncan Temple Lang. Functionality suggested by Jeroen Ooms.

References

libjson

See Also

Examples

isValidJSON(I('{"foo" : "bar"}'))

   isValidJSON(I('{foo : "bar"}'))
   isValidJSON('{foo : "bar"}', TRUE)

RJSONIO

Serialize R Objects to JSON, JavaScript Object Notation

v1.3-1.4
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2014), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>), Jonathan Wallace [aut] (aka ninja9578, author of included libjson sources)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.