title: MySQL JSON with arbitrary keys to table
body: <p>There is a map nested in a large json payload like</p>
  <pre><code>{
      &quot;map&quot;: {
          &quot;key1&quot;: &quot;value1&quot;,
          &quot;key2&quot;: &quot;value2&quot;,
          &quot;key3&quot;: &quot;value3&quot;
      },
      // more stuff
  }
  </code></pre>
  <p>I would like to generate a table like that:</p>
  <pre><code>+------#--------+
  | Key  | Value  |
  +------#--------+
  | key1 | value1 |
  | key2 | value2 |
  | key3 | value3 |
  +------#--------+
  </code></pre>
  <p>The only thing I can think of is writing a stored function that loops over JSON_KEYS to convert all key value pairs into</p>
  <pre><code>[{&quot;key&quot;:&quot;key1&quot;, &quot;value&quot;:&quot;value1&quot;}, {&quot;key&quot;:&quot;key2&quot;, &quot;value&quot;:&quot;value2&quot;}, ...]
  </code></pre>
  <p>which makes the task trivial with JSON_TABLE.</p>
  <p>Is there a faster and more elegant way?</p>