IsJson()

Evaluates whether a string is in valid JSON (JavaScript Object Notation) data interchange format.

IsJson( var=any, format=string );

Returns: Boolean

Argument Description Default
var
any, required

A string or variable that represents one.

Alias: value

format
string, optional

The format of the input string. Possible values are:

  • json: Standard JSON format
  • json5: JSON5 format which allows additional features such as comments and unquoted keys

Introduced: 6.2.0.14

json5

Examples

writeDump(label:"Array", var:isJson("[1,2,3]"));
writeDump(label:"Single number value", var:isJson(1));
writeDump(label:"String value", var:isJson('susi12345'));
writeDump(label:"String value with serializeJSON", var:isJson(serializeJSON('susi')));
writeDump(label:"Boolean value with serializeJSON", var:isJson(serializeJSON(true)));
writeDump(label:"CreateDateTime with serializeJSON", var:isJson(serializeJSON(CreateDateTime(2018,1,1,1,1,1))));
qry=queryNew('aaa,bbb', "varchar, varchar", [["a","b"],["c","d"]]);
writeDump(label:"Query", var: isJson(qry));

See also