I have a column in a BigQuery table known as change_json_string, which contains two sets of values that I need to extract. Given below is a sample record from said column:
{"old_value": {"variants": {"652442770:1070774498": {"choice_groups": {"652442771": {"choices": {"1070774500": {"price": "0"}}}}}}}],
"new_value": {"variants": {"652442770:1070774498": {"choice_groups": {"652442771": {"choices": {"1070774500": {"price": "1"}}}}}}}}
I need to extract the price from old_value and new_value (in other words, I need to find out what old price was and what the new price is). I would like to create two separate columns that extract the old price and the new price respectively.
I tried using the following code but it returned null values:
SELECT JSON_QUERY(change_json_string,'$.old_value.variants.price') AS old_value,
JSON_QUERY(change_json_string,'$.new_value.variants.price') AS new_value
I also tried using the following but again only saw null values:
SELECT JSON_QUERY(change_json_string,'$.old_value.variants[3].price') AS old_value,
JSON_QUERY(change_json_string,'$.new_value.variants[3].price') AS new_value
Any help on this would be greatly appreciated, thank you.