21.2. Validating JSON Data (json_valid) #

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

Where JSON is the JSON data that must be validated.

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

Postgres Pro AXE returns true if the JSON data is valid and false otherwise.

Example 21.2. Executing the json_valid Stored Procedure

JSON data in the j column of the example table:

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

Checking valid JSON data:

  SELECT json_valid(j) FROM example;
  true

Checking invalid JSON data:

  SELECT json_valid('invalid') ON CONFLICT DO NOTHING;
  false