21.12. Parsing and Removing Whitespace from JSON Data (json) #

Required privileges: All roles. 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(JSON) ON CONFLICT DO NOTHING;

Where JSON is the JSON data or a text string that must be converted to JSON, and from which whitespace must be removed.

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

Postgres Pro AXE converts the input to JSON and returns it with whitespace removed. If the input is not valid JSON, an error is returned.

Example 21.12. Executing the json Stored Procedure

JSON data in the j column of the example table:

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

Parsing and removing whitespace from JSON data:

  SELECT json(j) FROM example;
  {"family":"anatidae","species":["duck","goose","swan",null]}