JSON_EXTRACT

All functions > JSON > JSON_EXTRACT

Returns the value of the given JSON path in the given JSON expression.

Syntax

JSON_EXTRACT(expr, json_path)
sql

Arguments

ParameterTypeRequiredDescription
exprJSONYesThe JSON expression to extract from
json_pathJSONYesThe JSON path to extract (e.g., '$.field.subfield')

Returns

The JSON value at the specified path

Notes

  • Extracts values from JSON documents using JSONPath syntax
  • Supports nested field access with dot notation ($.field.subfield)
  • Supports array indexing ($.array[0])
  • Returns JSON type, preserving structure (objects, arrays, etc.)
  • Returns NULL if the path doesn't exist
  • Use JSON_EXTRACT_SCALAR for string values
  • JSONPath starts with $ representing the root

Examples

Last update at: 2025/10/13 10:23:46