Thank you for responding!
Good points.
However, I don't see consistency between the results of these two statements:
select jsonb_agg((select 1 where false));
select sum((select 1 where false));
Therefore another option I would like to suggest is returning the same null value-types for the sum() and json_agg().
So the select jsonb_agg((select 1 where false)); would return null as opposed to [null]. In this case it would be compatible with coalesce()
---
Thanks
Jordan Deitch