21.11. Aggregating JSON Data into a Structure (json_group_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_group_structure(JSON) ON CONFLICT DO NOTHING;

Where JSON is the JSON data that must be aggregated into a structure.

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

Postgres Pro AXE returns a JSON object where each key from the aggregated JSON data is mapped to its data type.

Example 21.11. Executing the json_group_structure Stored Procedure

JSON data in the j column of the example2 table:

  {
  "family": "anatidae",
  "species": ["duck", "goose"],
  "coolness": 42.42
  }
  {
  "family": "canidae",
  "species": ["labrador", "bulldog"],
  "hair": true
  }

Aggregating JSON data into a structure:

  SELECT json_group_structure(j) FROM example2;
  {"family":"VARCHAR","species":["VARCHAR"],"coolness":"DOUBLE","hair":"BOOLEAN"}