JSON_TYPE
Returns the datatype of the outermost element of a JSON value, or of the element at the optional path.
See also:
[SELECT] [DESCRIBE] [JSON_EXTRACT] [ Data Types ]
Use the DESCRIBE statement to locate array or object datatypes which can be used with StackQL JSON functions.
If you are using StackQL with a postgres SQL backend, use the json_typeof function instead.
Syntax
SELECT JSON_TYPE(json_array_or_object [, json_path])
FROM <multipartIdentifier>;
Arguments
json_array_or_object
A JSON array or object.
json_path
Optional. The JSON path to an array or object contained within a json_array_or_object. See jsonpath.com.
If json_path does not exist in json_array_or_object, then the function returns
NULL.
The
json_type()function throws an error if any of its arguments are not well-formed.
Return Value(s)
A string representing the resolved datatype.
Datatypes include
null,true,false,integer,real,text,array, orobject.
Examples
Return the datatype of a field nested within a JSON object or array
SELECT json_type(disks, '$[0].licenses[0]') as datatype
FROM google.compute.instances
WHERE project = 'stackql-demo'
AND zone = 'australia-southeast1-a';
/* returns text */
For more information, see https://www.sqlite.org/json1.html#jtype