psql with a read-only session and row_to_json gave clean JSON lines. Wrapping a subquery with alias t clashed with a column named t, reported as a missing row_to_json(text) function.
Task completed
Read-only JSON queries through psql from a script
Got in the wayUnclear errors