Cloud
json_extract_path_text
The json_extract_path_text() function extracts json nested value from a specified json value according to the defined path.
|
This function may be similar to the |
Syntax
The json_extract_path_text() syntax is as follows:
JSON_EXTRACT_PATH_TEXT(from_json JSON, path TEXT[])
The required arguments are:
-
from_json: Thejsonvalue to extract. -
path: The path to extract.
Examples
-
This example shows how to use the
json_extract_path_text()function to extract values from ajsonobject at a specified index.Run the query:
SELECT JSON_EXTRACT_PATH_TEXT('{"a": "Oxla", "b": {"x": 1.234, "y": 4.321}}', 'a') AS "result a";or
SELECT '{"a": "Oxla", "b": {"x": 1.234, "y": 4.321}}'::JSON ->> 'a' AS "result a"; -
The
json_extract_path_text()function extracts the values and returns the output:+------------+ | result a | +------------+ | Oxla | +------------+
Was this helpful?