|
I love `json_build_object()`. With `json_build_object()`, you can select fields as a JSON object and not have to do that JSON building in your app. Here's a snippet demonstrating building, and then querying a JSON object: with location as (select json_build_object(
'street1', street1,
'street2', street2,
'city', city,
'state', state,
'zip', zip
) as loc from my_table)
select
loc ->> 'street1' as street1,
loc ->> 'street2' as street2,
loc ->> 'city' as city,
loc ->> 'state' as state,
loc ->> 'zip' as zip
from location;
|
I guess my question is, to you, what's the main benefit of building JSON in the inthe DB instead of your app?