Table of Contents
validjson
Table of Contents
Prototype: validjson(data_container)
Return type: boolean
Description: Validates a JSON container from data_container
and returns
true
if the contents are valid JSON.
Arguments:
data_container
:string
, in the range:.*
Example:
Run:
bundle agent main
{
vars:
"json_string" string => '{"test": [1, 2, 3]}';
reports:
"This JSON string is valid!"
if => validjson("$(json_string)");
"This JSON string is not valid."
unless => validjson("$(json_string)");
}
Output:
R: This JSON string is valid!
See also: readjson()
, validdata()
History: Was introduced in 3.16.0.