I worked around it by using select json_agg(t)... and redirecting it tofile via psql on the command line. COPY TO was working until we ran intobroken JSON and discovered the double quoting issue due to some valuescontaining " in them.