> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# get_json_bool

> Parses and gets the boolean value from a specified JSON path in a JSON string.

Parses and gets the boolean value from a specified JSON path in a JSON string.

**Tip**

All of the JSON functions and operators are listed in the navigation and on the [overview page](/documents/4.2/sql-reference/sql-functions/json-functions/overview-of-json-functions-and-operators.md)

Accelerate your queries with [generated columns](/documents/4.2/sql-reference/sql-statements/generated_columns.md)

If the format of `json_str` or `json_path` is invalid, or if no matching content can be found, this function will return NULL.

This function is supported from v3.3.

## Syntax

```Haskell theme={null}
BOOLEAN get_json_bool(VARCHAR json_str, VARCHAR json_path)
```

## Parameters

* `json_str`: the JSON string. The supported data type is VARCHAR.
* `json_path`: the JSON path. The supported data type is VARCHAR.

  * `json_path` must start with `$` and use `.` as the path separator. If the path includes `.`, it can be enclosed in a pair of `"`.
  * `[ ]` is used as the array subscripts which starts from 0.

## Examples

1. Get the value whose key is "k1". The value is `true` and `1` is returned.

   ```Plain Text theme={null}
   MySQL > SELECT get_json_bool('{"k1":true, "k2":"false"}', "$.k1");
   +----------------------------------------------------+
   | get_json_bool('{"k1":true, "k2":"false"}', '$.k1') |
   +----------------------------------------------------+
   |                                                  1 |
   +----------------------------------------------------+
   ```

2. Get the second element in the array whose key is "my.key". The second element is `false` and `0` is returned.

   ```Plain Text theme={null}
   SELECT get_json_bool('{"k1":"v1", "my.key":[true, false, 3]}', '$."my.key"[1]');
   +--------------------------------------------------------------------------+
   | get_json_bool('{"k1":"v1", "my.key":[true, false, 3]}', '$."my.key"[1]') |
   +--------------------------------------------------------------------------+
   |                                                                        0 |
   +--------------------------------------------------------------------------+
   ```

3. Get the first element in the array whose path is `k1.key -> k2`. The first element is `false` and `0` is returned.

   ```Plain Text theme={null}
   MYSQL > SELECT get_json_bool('{"k1.key":{"k2":[false, true]}}', '$."k1.key".k2[0]');
   +----------------------------------------------------------------------+
   | get_json_bool('{"k1.key":{"k2":[false, true]}}', '$."k1.key".k2[0]') |
   +----------------------------------------------------------------------+
   |                                                                    0 |
   +----------------------------------------------------------------------+
   ```

## keyword

GET\_JSON\_BOOL,GET,JSON,BOOL


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.