Guyren Howe <guyren@gmail.com> writes:
> I have an array of perfect JSON objects. Now I just need to turn that into a single JSON object. But when I do the
obvious:
> SELECT array_to_json(
> SELECT
> ARRAY_AGG(foo) AS foos
> FROM (
> SELECT
> row_to_json(schemata_)
> FROM
> schemata_)
> AS
> foo
> )
> I get a syntax error.
Well, yeah, you're missing parentheses around the scalar sub-select.
(Whether fixing that will give the behavior you want is unclear,
but the syntax error is clear.)
regards, tom lane