Thanks, Tom. Doing something like:
with t as ( select somekey, someotherkey from mytable ) select json_agg(t)->0 from t;
Feels a lot more, errr, natural. Would rather have the object than an array of 1 containing the object, thus the ->0 but this works well and feels SQL-ish indeed.
On Tue, Jan 26, 2021 at 1:42 PM Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
Wells Oliver <wells.oliver@xxxxxxxxx> writes:
> Yeah, thanks, I thought about that: concatenating a few different objects
> to make a bigger object. Seemed silly, but if there's not a cleaner
> solution, it does work.
A more SQL-ish way to deal with this might be to use jsonb_agg()
or jsonb_object_agg().
regards, tom lane
Wells Oliver
wells.oliver@xxxxxxxxx
wells.oliver@xxxxxxxxx