I have Json string with two levels: list[json{list[json]}]:
UserID Json_List
100 [{"application_charge":{"id":13409353813,"name":"Starter","api_client_id":2485321},"usage_charges":[{"id":48216805,"description":"Extras","price":"60.70"}]}]
200 [{"application_charge":{"id":13409353814,"name":"Starter","api_client_id":2485322},"usage_charges":[{"id":48216890,"description":"Extras","price":"80.79"}]}]
Need Output like table :
UserID application_charge.id name api_client_id usage_charges.id description price
100 13409353813 Starter 2485321 48216805 Extras 60.7
200 13409353814 Starter 2485322 48216890 Extras 80.79
I manage to pull out the first step "application_charge" but do not understand how to get to the next step "usage_charges"
select
UserID,
json_extract_scalar(json, '$.application_charge.id') as id,
json_extract_scalar(json, '$.application_charge.name') as name,
json_extract_scalar(json, '$.application_charge.api_client_id') as api_client_id
from `be-prod-data.retailers_billing_data_production.shopify_application_charges`,
unnest(json_extract_array( json_list, '$')) json
How can I extract data from the second stage ??
