I have predictions stored in a JSON field in a mysql table as follow
SELECT id, value from predictions
id | value |
+--------------------------+
1 | {"class1": 0.99, "class2": 0.05}
2 | {"class1": 0.94, "class2": 0.01, "class3": 0.4}
...
Each row contains a dictionary with (potentially) different keys, but each dictionnary follows this schema.
I'd like to deserialize this into a key-value result like below:
id | class | confidence |
+------------------------+
1 | class1 | 0.99 |
1 | class2 | 0.05 |
2 | class1 | 0.94 |
2 | class2 | 0.01 |
2 | class3 | 0.4 |
Were the JSON in the format of a list containing one dictionary for each predicted class, I could have used the JSON_TABLE as I am using MySQL > 8.0, however I am at a loss on how to do so.