21.5. Получение JSON-структуры (json_structure) #

Требуемые права: только администратор Postgres Pro AXE. За полным списком хранимых процедур и прав обратитесь к Разделу 12.1.

Выполните следующую команду на сервере Postgres Pro AXE:

  SELECT json_structure(JSON);

Где JSON — это JSON-данные, структуру которых требуется получить.

Необходимо указать строковой литерал JSON или столбец с JSON-данными.

Postgres Pro AXE возвращает структуру JSON-данных. Если JSON-данные содержат массив с элементами разных типов данных, в возвращаемой структуре типом данных этих элементов является JSON.

Пример 21.5. Выполнение хранимой процедуры json_structure

JSON-данные в столбце j таблицы example:

  {
  "family": "anatidae",
  "species": ["duck", "goose", "swan", null]
  }

Получение JSON-структуры:

  SELECT json_structure(j) FROM example;
  {"family":"VARCHAR","species":["VARCHAR"]}

21.5. Retrieving the JSON Structure (json_structure) #

Required privileges: Postgres Pro AXE administrator only. For a full list of stored procedures and privileges, refer to Section 12.1.

Execute the following command on the Postgres Pro AXE server:

  SELECT json_structure(JSON);

Where JSON is the JSON data whose structure must be retrieved.

You must specify a JSON string literal or a column with JSON data.

Postgres Pro AXE returns the structure of the JSON data. If the JSON data contains an array with elements of different data types, the data type of these elements in the returned structure is JSON.

Example 21.5. Executing the json_structure Stored Procedure

JSON data in the j column of the example table:

  {
  "family": "anatidae",
  "species": ["duck", "goose", "swan", null]
  }

Retrieving the JSON structure:

  SELECT json_structure(j) FROM example;
  {"family":"VARCHAR","species":["VARCHAR"]}

FAQ