# TRY_JQ()

## Function Description

The `TRY_JQ()` function is used to parse and convert JSON data based on jq expressions. Unlike [`JQ()`](https://omnifabric.cloudsigma.com/docs/reference/sql/Functions-and-Operators/Json/jq.html.md), `TRY_JQ()` supports returning null values when an error occurs, while `JQ()` directly throws an exception when an error occurs.

## Grammar Structure

```sql
select try_jq(jsonDoc, pathExpression);
```

## Parameter definition

| Parameters | Description |
| ---- | ---- |
| jsonDoc | This is a column or expression containing JSON data. |
| pathExpression | Used to specify how fields are extracted from JSON data |

## Example

```text
mysql> select try_jq('{"foo": 128}', '.foo');
+----------------------------+
| try_jq({"foo": 128}, .foo) |
+----------------------------+
| 128                        |
+----------------------------+
1 row in set (0.00 sec)

mysql> select try_jq(null, '.foo');
+--------------------+
| try_jq(null, .foo) |
+--------------------+
| NULL               |
+--------------------+
1 row in set (0.00 sec)

mysql> select try_jq('{"id": "sample", "10": {"b": 42}}', '{(.id): .["10"].b}');
+---------------------------------------------------------------+
| try_jq({"id": "sample", "10": {"b": 42}}, {(.id): .["10"].b}) |
+---------------------------------------------------------------+
| {"sample":42}                                                 |
+---------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select try_jq('[1, 2, 3]', '.foo & .bar');
+--------------------------------+
| try_jq([1, 2, 3], .foo & .bar) |
+--------------------------------+
| NULL                           |
+--------------------------------+
1 row in set (0.00 sec)
```
