In PostgreSQL, to_json() converts a value to JSON format.

Structure

to_json(value)

Example

SELECT
to_json("Peter") AS "name",
to_json(100) AS "employee_id",
to_json(true) AS "active"

Output

name employee_id active
Peter 100 true