TO_JSONB
Converts a value — a number, text, an array or a whole table row — to JSON.
Syntax
TO_JSONB(<value>)
A number becomes a JSON number, text a JSON string, an array a JSON array. If you pass the table row itself (its alias in the query), you get an object with all the columns — handy for sending a record to the application in one field or saving it to a change log.