JSON_TYPE
Returns the datatype of the outermost element of an input JSON object or array and path.
See also:
[SELECT
] [DESCRIBE
] [JSON_EXTRACT
] [ Data Types ]
Use the DESCRIBE function to locate array
or object
datatypes which can be used with StackQL JSON functions.
The json_type
function is implemented as the json_typeof
function if you are using stackql with a postgres
sql backend
Syntax
SELECT JSON_TYPE(json_array_or_object, json_path)
FROM <multipartIdentifier>;
Arguments
json_array_or_object
A JSON array or object.
json_path
The JSON path to an array or object contained within an 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