Why is Postgres jsonb_agg function wrapping the output into additional JSON field?
<code>SELECT jsonb_agg(t) AS json_array
FROM (SELECT jsonb_set('[{"f1": "1","f2": null}, 2, null, 3]', '{0,f1}', '"DELETEME"',true)) t
</code>
<code>SELECT jsonb_agg(t) AS json_array
FROM (SELECT jsonb_set('[{"f1": "1","f2": null}, 2, null, 3]', '{0,f1}', '"DELETEME"',true)) t
</code>
SELECT jsonb_agg(t) AS json_array
FROM (SELECT jsonb_set('[{"f1": "1","f2": null}, 2, null, 3]', '{0,f1}', '"DELETEME"',true)) t
And it returns this:
<code>[{"jsonb_set": [{"f1": "DELETEME", "f2": null}, {"f3": "1", "f4": null}]}]
</code>
<code>[{"jsonb_set": [{"f1": "DELETEME", "f2": null}, {"f3": "1", "f4": null}]}]
</code>
[{"jsonb_set": [{"f1": "DELETEME", "f2": null}, {"f3": "1", "f4": null}]}]
How to avoid such behaviour? As I need it to return:
<code>[{"f1": "DELETEME", "f2": null}, {"f3": "1", "f4": null}]
</code>
<code>[{"f1": "DELETEME", "f2": null}, {"f3": "1", "f4": null}]
</code>
[{"f1": "DELETEME", "f2": null}, {"f3": "1", "f4": null}]