Extracting and Converting JSON Values
On this page
Extracting JSON Values
subvalue_
specifies which subvalues are extracted and the column or variable to which each one is assigned.
LOAD DATA
uses the ::
-separated list of keys in a subvalue_
to perform successive key lookups in nested JSON objects, as if applying the ::
SQL operator.::
operator, subvalue_
may not be used to extract an element of a JSON array.%
refers to the entire JSON value being processed.%::
may be omitted from paths which are otherwise non-empty.
If a path can’t be found in an input JSON value, then if the containing element of subvalue_
has a DEFAULT
clause, its literal_
will be assigned; otherwise, LOAD DATA
will terminate with an error.
Path components containing whitespace or punctuation must be surrounded by backticks.%::`a.
and `a.
will both extract 1
from the input object {"a.
.
Array elements may be indirectly extracted by applying JSON_
in a SET
clause.
Converting JSON Values
Before assignment or set clause evaluation, the JSON value extracted according to a subvalue_
is converted to a binary collation SQL string whose value depends on the extracted JSON type as follows:
JSON Type |
Converted Value |
---|---|
|
SQL |
|
|
|
Verbatim, from extracted string. |
|
All JSON string escape sequences, including escape sequences are converted to UTF-8. |
|
Verbatim, from extracted string. |
|
Verbatim, from extracted string. |
Conversion is not recursive.true
is not converted to "1"
when it is a subvalue of an object which is being extracted whole.
Last modified: April 3, 2025