0
\$\begingroup\$

I have a json field in a table that I want to select certain fields from into a new json field. So far I have this, which works, but I feel may not be optimal:

select to_json(new_obj) from (
    select big_json_field->'json_property_1' as json_property_1, 
    big_json_field->'json_property_2' as json_property_2 
    from table_with_big_json_field
) as new_obj

Is there a function or method I'm missing to optimize this?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.