Functions to help build JSON objects in PostgreSQL