We have a database table in MySQL8 (and MariaDB in some deployments) with two columns which each store a JSON array, like
| Col A | Col B |
|---|---|
| ['a', 'b', 'c'] | [10, 20, 30] |
Ultimately, we need to create a JSON object from those two arrays that uses Col A as keys and Col B as values, like so
{
a: 10,
b: 20,
c: 30
}
I thought I could use the MySQL function JSON_OBJECT for that, but that requires me to interleave the two columns into one list, which I also struggle with. I guess you could also make use of the JSON_TABLE function in a smart way, but I didn't come up with a solution yet.
I thought this would be a simple task, but it isn't, at least not to me. Can someone with better knowledge of MySQL guide me?