I have a table that I am trying to parse data out of.
data
{ "user": "user123",
"Itemsbought": [
{ "Item": "X", "Costdollars": ["20", "30", "40", "50"]},
{ "Item": "Y", "costdollars": ["30", "40", "50", "60"]},
{ "Item": "Z", "costdollars": ["40", "50", "60", "70"]}
}
I am trying to parse out specific information to get it to look something like this:
User Item Cost
user123 X ["20", "30", "40", "50"]
user123 Y ["30", "40", "50", "60"]
user123 Z ["40", "50", "60", "70"]
When I am writing code for this, I am able to parse out some of what I want but getting an error or NULL result when trying to break out the cost section
Code:
SELECT
json_value(data,'$.user') as user,
json_value(data,'$.Itemsbought.item') as item,
json_value(data,'$.Itemsbought.item.costdollars') as cost
from users
I dont have as much experience parsing out json data. I saw json_value is doing part of the job but not getting exactly what i was trying to do.