SQLite 3 reference · JSON Functions

SQLite JSON_TYPE() Function

Return the JSON type of a value or path: 'null', 'true', 'false', 'integer', 'real', 'text', 'array' or 'object'.

SQLite 3 Since 3.9.0

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

json_type(json, path)

Parameters

ParameterDescription
json JSON text (or JSONB).
path optional The element to inspect.

Return value

Text, or NULL if the path doesn't exist.

Examples

Inspect typesTry it yourself
SELECT json_type('{"a":[1,2]}') AS root, json_type('{"a":[1,2]}', '$.a') AS a, json_type('{"a":[1,2]}', '$.a[0]') AS first;

Output

root | a | first
object | array | integer
Booleans and missing pathsTry it yourself
SELECT json_type('{"ok":true}', '$.ok') AS ok, json_type('{"ok":true}', '$.missing') AS missing;

Output

ok | missing
true | NULL

Version history

VersionChange
SQLite 3.9.0Added
SQLite 3.38.0Built in by default; earlier versions needed the JSON1 extension.

In other languages

Was this page helpful?