The drizzle example I linked to is a realistic example into what would actually be involved in using JSON aggregation in the datbase in PG. Its painful to write manually.
I wish postgres had FOR JSON (https://learn.microsoft.com/en-us/sql/relational-databases/j...)