# JSON\_EXTRACT\_FIRST

```
JSON_EXTRACT_FIRST (json_string,pattern)
```

Interprets ‘pattern’ as a Json path pattern and applies it to ‘json\_string’, returning the first match, as a string containing valid json. Examples for the pattern parameter: “$.a”, “$\[‘a’]”, “$\[0]”, “$.points\[?(@\[‘id’]==‘i4’)].x”, “$\[‘points’]\[?(@\[‘y’] >= 3)].id”, “$.conditions\[?(@ == false)]”

Available in:

| Processors | SQL Studio |
| ---------- | ---------- |
| ✓          | ✓          |

*Sample code:*

```sql
USE `kafka`;
SELECT 
    JSON_EXTRACT_FIRST(time_details, '$.hour'), 
    time_details 
FROM credit-card-transactions
LIMIT 2;
```

*Output:*

{% code fullWidth="true" %}

```json
{
  "value": {
    "JSON_EXTRACT_FIRST": "1",
    "time_details": "{\"hour\": 1, \"minute\": 17, \"second\": 15, \"millisecond\": 36}"
  }
}
{
  "value": {
    "JSON_EXTRACT_FIRST": "16",
    "time_details": "{\"hour\": 16, \"minute\": 23, \"second\": 2, \"millisecond\": 255}"
  }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/user-guide/using/sql-reference/functions/json/json_extract_first.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
