Skip to main content
Accepts an expression containing a JSON document, a JSON path expression, and an optional path syntax. If the key specified in the JSON path exists, JSON_EXTRACT returns the sub-JSON document at the specified path, and otherwise, returns NULL.

Syntax

Aliases

Parameters

Return Type

TEXT
  • If any input values are NULL, the function will return NULL.

Examples

For the JSON document used in the examples below, see JSON common example. Example The following code example extracts the value at the path /value/dyid from the JSON document using the JSONPointer syntax and returns "987":

Rows: 1Execution time: 4.86ms

Example The following code example attempts to extract a value from the path /value/no_such_key and returns NULL because the key does not exist:

Rows: 1Execution time: 4.98ms

Example The following code example extracts the value at the path /value/uid using the JSON_POINTER_EXTRACT alias and returns '"987654"' with double quotes, indicating it is a JSON string:

Rows: 1Execution time: 8.19ms

Example The following code example extracts the array at the path /value/keywords using the JSON_POINTER_EXTRACT alias:

Rows: 1Execution time: 6.28ms

Example The following code example extracts the third element at index 2 from the keywords array using zero-based indexing:

Rows: 1Execution time: 5.55ms