When using the regular syntax to write your XQL queries and a field in the <json_path>
contains characters, such as a dot (.) or colon (:), the syntax needs to be tweaked slightly to account for the <json_field>
.
For example, when using the json_extract
function, the previous regular syntax would need to be changed to an updated syntax to account for the field in the <json_path>
containing characters.
Previous regular syntax for the json_extract
function:
json_extract(<json_object_formatted_string>, <json_path>)
Updated regular syntax for the json_extract
function, where the <json_field>
now includes single quotation marks as '<json_field>'
:
json_extract(<json_object_formatted_string>, "['<json_field>']")
For each JSON function, the regular syntax can change slightly, but the "['<json_field>']"
format is the same. The "['<json_field>']"
identifies the data you want to extract using dot-notation, where the data extracted is dependent on your syntax.
If you have the following JSON object defined:
{"a.b":
{"inn":
{"one":1}
}
}
To extract the data {"one":1}
, the "['<json_field>']"
would need to be defined as "$['a.b'].inn"
for all JSON functions. For example, when using the json_extract
function, the regular syntax is:
json_extract(field_json_1, "$['a.b'].inn")
To extract the data {"inn": {"one":1}}
, the "['<json_field>']"
would need to be defined as "$['a.b']"
for all JSON functions. For example, when using the json_extract
function, the regular syntax is:
json_extract(field_json_1, "$['a.b']")
If you have the following JSON object defined:
{"a.b":
{"inn.inn":
{"one":1}
}
}
To extract the data {"one":1}
, the "['<json_field>']"
would need to be defined as "$['a.b']['inn.inn']"
for all JSON functions. For example, when using the json_extract
function, the regular syntax is:
json_extract(json_field, "$['a.b']['inn.inn']")