How to query json stored as string in bigquery table?
I have a table where value in a column (subscriptions) looks like this:
{
"data": [{
"application_fee_percent": null,
"canceled_at": null,
"created": 1500476240,
"items": {
"data": [{
"created": 1500476240,
"id": "s4nQMWJn4P1Lg",
"metadata": {},
"object": "subscription_item",
"plan": {
"amount": 3,
"created": 1494270926,
"currency": "usd",
"livemode": true,
"metadata": {
"currentlySelling": "true",
"features": "{\"shipping\": true,\"transactionFee\":0.00}",
"marketingFeatures": "[\"Unlimited products\"]"
},
"name": "Personal",
"object": "plan",
"statement_descriptor": null,
"trial_period_days": null
},
"quantity": 1
}],
"has_more": false,
"object": "list",
"total_count": 1,
"url": "/v1/subscri3XwjA3"
},
"livemode": true,
"metadata": {
"test": "596f735756976"
},
"object": "suion",
"quantity": 1
}],
"has_more": false,
"object": "list",
"total_count": 1,
"url": "/v1/cutions"
}
How can I select application_fee_percent, features, and marketingFeatures?
For created, I tried
JSON_EXTRACT("subscriptions", "$.data[0].created")
but it's returning null.
JSON_EXTRACTwith it unless maybe there was a mistake in transcription. - Elliott Brossard