# JSON_TYPE

> JSON_TYPE function in StackQL: the type (object, array, text, integer, real, true, false or null) of a JSON value's outermost element, or of a path within it.

Source: https://stackql.io/language-spec/functions/json/json_type

Returns the datatype of the outermost element of an input JSON object or array and path.  

See also:  
[[` SELECT `]](/language-spec/select) [[` DESCRIBE `]](/language-spec/describe) [[` JSON_EXTRACT `]](/language-spec/functions/json/json_extract) [[ Data Types ]](/language-spec/data-types)

* * * 

:::tip 

Use the [**DESCRIBE**](/language-spec/describe) function to locate `array` or `object` datatypes which can be used with StackQL JSON functions.

:::

:::note 

The `json_type` function is implemented as the `json_typeof` function if you are using stackql with a `postgres` sql backend

:::

## Syntax

```sql
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](https://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`, or `object`.

* * *

## Examples

### Return the datatype of a field nested within a JSON object or array

```sql
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](https://www.sqlite.org/json1.html#jtype)
