Skip to main content Skip to complementary content

IsJson - script and chart function

IsJson() tests whether a specified string contains valid JSON (JavaScript Object Notation) data. You can also validate a specific JSON data type.

Syntax:

value IsJson(json [, type])

Return data type: dual

Arguments
Argument Description
json String to test. It can contain extra spaces or newlines.
type

Optional argument that specifies the JSON data type to test for.

  • 'value' (default)

  • 'object'

  • 'array'

  • 'string'

  • 'number'

  • 'Boolean'

  • 'null'

Example: Valid and invalid chart expressions
Example Result
IsJson( 'null' ) Returns -1 (true)
IsJson( '"abc"', 'value' ) Returns -1 (true)
IsJson( '"abc"', 'string' ) Returns -1 (true)
IsJson( 123, 'number' ) Returns -1 (true)
IsJson( 'text' ) Returns 0 (false), 'text' is not a valid JSON value
IsJson( '"text"', 'number' ) Returns 0 (false), '"text"' is not a valid JSON number
IsJson( '"text"', 'text' ) Returns 0 (false), 'text' is not a valid JSON type

Example - IsJson fundamentals

Example - IsJson scenario

See also:

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!