There is a column that holds a json formatted value.
id| statuses |
--+---------------------------+
1 | { "a": true, "b": false } |
2 | { "c": true } |
Is it possible to turn it into a table as below?
id | statusName | value
---+------------+------------------
1 | a | true
1 | b | false
2 | c | true
I found JSON_TABLE
functions (from this document), but its usage seems to be applicable only when you already know the keys but that is not the case. If only I could extract the keys in json there might be a way, but is it possible?
SELECT JT.*
FROM JSON_TABLE(<tableName>.statuses , '$')
COLUMNS
(
VALUE BOOLEAN PATH '$.*'
)
) AS JT; --did not work