Repository navigation
Description
Problem
PostgreSQL jsonb[] columns display as raw PostgreSQL array literals, with each JSON object quoted and escaped. This makes nested values difficult to inspect, even though the elements are genuine JSON objects.
Merged PR #2110 added element-by-element editing for arrays of simple types, including enums, but explicitly excluded jsonb[] because its additional escaping layer requires separate round-trip handling. This request extends that existing support with readable JSON inspection.
Reproduction
- In a disposable PostgreSQL database, create this example:
CREATE TABLE jsonb_array_test (
id serial PRIMARY KEY,
items jsonb[]
);
INSERT INTO jsonb_array_test (items)
VALUES (
ARRAY[
'{"id": 1, "name": "example", "metadata": {"enabled": true, "tags": ["one", "two"]}}'::jsonb,
'{"id": 2, "name": "another", "metadata": {"enabled": false, "tags": ["three"]}}'::jsonb
]
);- Verify the types:
SELECT
pg_typeof(items) AS column_type,
jsonb_typeof(items[1]) AS first_element_type,
jsonb_typeof(items[2]) AS second_element_type
FROM jsonb_array_test;Verified result: jsonb[], object, object.
- Run the comparison and inspect both result cells:
SELECT
items,
to_jsonb(items) AS items_as_jsonb
FROM jsonb_array_test;The items cell shows escaped array syntax, while items_as_jsonb uses the formatted JSON viewer. The inspector labels in the screenshot are json[] and json, although PostgreSQL confirms the source column is jsonb[].
Screenshot
Reproduced with PostgreSQL 16.11 running locally in Docker, TablePro 0.74.0 (130), macOS 27.0, Apple M4 Pro (Apple Silicon).
Proposed solution
Allow opening a jsonb[] cell in a formatted JSON viewer, comparable to the existing viewer for to_jsonb(items), without requiring a conversion in every query.
A read-only formatted preview would be a useful first step while preserving the original PostgreSQL array value. Keep the raw representation available for unsupported array shapes.
Any later editing support should preserve SQL NULL versus JSON null, array dimensions, and lower bounds, with round-trip tests.
Alternatives considered
Using to_jsonb(items) in a SELECT query works and produces readable JSON, as shown above, but requires a custom query instead of inspecting the column directly while browsing a table.
The current raw-text editor preserves PostgreSQL array syntax but makes nested JSON difficult to read.
Related database type
PostgreSQL
Activity