# 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.<br><br><ul> <li> <p>'value' (default)</p> </li> <li> <p>'object'</p> </li> <li> <p>'array'</p> </li> <li> <p>'string'</p> </li> <li> <p>'number'</p> </li> <li> <p>'Boolean'</p> </li> <li> <p>'null'</p> </li> </ul> |

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/IsJson.htm)

#### Example: Valid JSON and type

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

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/IsJson.htm)

#### Example: Invalid JSON or type

| Example | Result | Description |
| --- | --- | --- |
| `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 |

See also:

* [JsonGet - script and chart function](https://help.qlik.com/en-US/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/JsonGet.htm)

* [JsonSet - script and chart function](https://help.qlik.com/en-US/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/JsonSet.htm)