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 |
Published by Muhammad Asfour
Estimated reading time: 1 min
In PostgreSQL, to_json()
converts a value to JSON format.
to_json(value)
SELECT
to_json("Peter") AS "name",
to_json(100) AS "employee_id",
to_json(true) AS "active"
name | employee_id | active |
---|---|---|
Peter | 100 | true |