↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / Json Functions And Operators

jsonb_object

Read the PG 18 manual

Builds a JSON object out of a text array.

Reading PG 18current·documented in 13 of 27 versions, 9.5 to 20

Signatures & examples

jsonb_object ( text[] ) → jsonb
Builds a JSON object out of a text array. The array must have either exactly one dimension with an even number of members, in which case they are taken as alternating key/value pairs, or two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair. All values are converted to JSON strings.
json_object('{a, 1, b, "def", c, 3.5}') → {"a" : "1", "b" : "def", "c" : "3.5"}
json_object('{{a, 1}, {b, "def"}, {c, 3.5}}') → {"a" : "1", "b" : "def", "c" : "3.5"}
jsonb_object ( keys text[], values text[] ) → jsonb
This form of json_object takes keys and values pairwise from separate text arrays. Otherwise it is identical to the one-argument form.
json_object('{a,b}', '{1,2}') → {"a": "1", "b": "2"}
Version history 2
  1. 12 → 13 changed
  2. 9.4 → 9.5 added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source