Pre-General Availability Draft: 2017-09-22
Many of the functions described in previous sections require a
path expression in order to identify a specific element in a JSON
document. A path consists of the path's scope followed by one
or more path legs. For paths used in MySQL JSON functions, the
scope is always the document being searched or otherwise operated
on, represented by a leading
$ character. Path
legs are separated by period characters (
Cells in arrays are represented by
N is a non-negative integer. Names of
keys must be double-quoted strings or valid ECMAScript identifiers
Path expressions, like JSON text, should be encoded using the
utf8mb4 character sets. Other character
encodings are implicitly coerced to
The complete syntax is shown here:
pathExpression: scope[(pathLeg)*] pathLeg: member | arrayLocation | doubleAsterisk member: period ( keyName | asterisk ) arrayLocation: leftBracket ( nonNegativeInteger | asterisk ) rightBracket keyName: ESIdentifier | doubleQuotedString doubleAsterisk: '**' period: '.' asterisk: '*' leftBracket: '[' rightBracket: ']'
As noted previously, in MySQL, the scope of the path is always the
document being operated on, represented as
You can use
'$' as a synonynm for the document
in JSON path expressions.
Some implementations support column references for scopes of JSON paths; currently, MySQL does not support these.
are used as follows:
.*represents the values of all members in the object.
[*]represents the values of all cells in the array.
[represents all paths beginning with
prefixand ending with
prefixis optional, while
suffixis required; in other words, a path may not end in
In addition, a path may not contain the sequence
For path syntax examples, see the descriptions of the various JSON
fuinctions that take paths as arguments, such as
JSON_REPLACE(). For examples which
include the use of the
** wildcards, see the description of the