JSONPath Syntax
JSONPath in MySQL: $ is the document root, .key selects a key, [n] selects an array index, [*] selects all elements.
JSONPath in MySQL: $ is the document root, .key selects a key, [n] selects an array index, [*] selects all elements.
-- Given: {"user": {"name": "Alice", "tags": ["admin", "dev"]}}
SELECT
data->'$.user.name', -- "Alice"
data->'$.user.tags[0]', -- "admin"
JSON_EXTRACT(data, '$.user.tags[*]') -- ["admin","dev"]
FROM settings WHERE id = 1;
Use [last] to select the last element of a JSON array.