I want to choose which to extract and show it to each column, I want to have result like this query, but don't want to type this for every single thing like this
Select *,
metrics::json ->> 'spend',
metrics::json ->> 'impressions',
metrics::json ->> 'clicks'
from t1
this show null, How to do if I choose to extract 'reach' and 'clicks',... to column but not all in the json?
select *
from json_to_record('{"reach": 240, "spend": 3.34, "clicks": 10, "frequency": 1.0375}')
as x(a int, b text, d text, e text)
I refer this Stack over flow question
EDIT: I have the main question is: how to choose which to extract without extract all like the 2nd query? The data have many rows, each row have json, can I do that with
Json_to_record
?