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) ON CONFLICT DO NOTHING;

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"]}