Description\n-----------\n\nA number of JSON functions accept JSON Path expressions. MariaDB defines this path as follows:\n\nJSON Path Syntax\n\n``sql\npath : ['lax'] '$' [step]\n`\n\nThe path starts with an optional _path mode_. At the moment, MariaDB supports only the "lax" mode, which is also the mode that is used when it is not explicitly specified.\n\nThe $ symbol represents the context item. The search always starts from the context item; because of that, the path always starts with $.\n\nThen, it is followed by zero or more steps, which select element(s) in the JSON document. A step may be one of the following:\n\n Object member selector.\n Array element selector.\n Wildcard selector.\n\nObject Member Selector\n\nTo select member(s) in a JSON object, one can use one of the following:\n\n .memberName selects the value of the member with name memberName.\n ."memberName" - the same as above but allows one to select a member with a name that's not a valid identifier (that is, has space, dot, and/or other characters).\n . - selects the values of all members of the object.\n\nIf the current item is an array (instead of an object), nothing will be selected.\n\nArray Element Selector\n\nTo select elements of an array, one can use one of the following:\n\n [N] selects element number N in the array. The elements are counted from zero.\n [] selects all elements in the array.\n\nIf the current item is an object (instead of an array), nothing will be selected.\n\nJSON path supports negative indexes in an array, 'last' keyword and range notation ('to' keyword) for accessing array elements. Negative indexes start from -1.\n\n [-N] selects n th element from end.\n [last-N] selects n th element from the last element.\n [M to N] selects range of elements starting from index M to N.\n\nExample:\n\n`sql\nSET @json='{\n            "A": [0,\n                  [1, 2, 3],\n                  [4, 5, 6],\n                  "seven",\n                   0.8,\n                   true,\n                   false,\n                   "eleven",\n                  [12, [13, 14], {"key1":"value1"},[15]],\n                  true],\n            "B": {"C": 1},\n            "D": 2\n           }';\nSELECT JSON_EXTRACT(@json, '$.A[-8][1]');\n+--------------------------------------------------+\n| JSON_EXTRACT(@json, '$.A[-8][1]')                |\n+--------------------------------------------------+\n| 5                                                |\n+--------------------------------------------------+\n\nSELECT JSON_EXTRACT(@json, '$.A[last-7][1]');\n+-----------------------------------------------+\n| SELECT JSON_EXTRACT(@json, '$.A[last-7][1]'); |\n+-----------------------------------------------+\n| 5                                             |\n+-----------------------------------------------+\n\nSET @json= '[\n             [1, {"key1": "value1"}, 3],\n             [false, 5, 6],\n             [7, 8, [9, {"key2": 2}, 11]],\n             [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],\n             [19, 20],\n             21, 22\n            ]';\n\nSELECT JSON_EXTRACT(@json, '$[0 to 3][2]');\n+-----------------------------------------------+\n| JSON_EXTRACT(@json, '$[0 to 3][2]')           |\n+-----------------------------------------------+\n| [3, 6, [9, {"key2": 2}, 11], [14]]            |\n+-----------------------------------------------+\n`\n\nJSON path does not support negative indexes in an array.\n\nThis produces output for first index of eighth from last element of a two dimensional array.\n\nNote: In range notation, when M > N ( when M,N are greater than or equal to 0) or (size of array - M or size of array - N when M, N are less than 0), then it is treated as an impossible range and NULL is returned.\n\n`sql\nSET @json= '[1, 2, 3, 4, 5]';\nSELECT JSON_EXTRACT(@json, '$[4 to 2]');\n+-----------------------------------+\n| JSON_EXTRACT(@json, '$[4 to 2]')  |\n+-----------------------------------+\n| NULL                              |\n+-----------------------------------+\n`\n\nWildcard\n\nThe wildcard step, , recursively selects all child elements of the current element. Both array elements and object members are selected.\n\nThe wildcard step must not be the last step in the JSONPath expression. It must be followed by an array or object member selector step.\n\nFor example, this query selects all object members named price in the document:\n\n`sql\nSELECT json_extract(@json_doc, '$.price');\n`\n\nThis query, however, selects the second element in each of the arrays present in the document:\n\n`sql\nSELECT json_extract(@json_doc, '$[2]');\n`\n\nCompatibility\n\nMariaDB's JSONPath syntax supports a subset of JSON Path's definition in the SQL Standard. The most notable things not supported are the strict mode and filters.\n\nMariaDB's JSONPath is close to MySQL's JSONPath. The wildcard step (  ) is a non-standard extension that has the same meaning as in MySQL. The difference between MariaDB and MySQL's JSONPath is: MySQL doesn't allow one to specify the mode explicitly (but uses lax` mode implicitly).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/jsonpath-expressions