How to turn a json array into rows in postgres
<p>I have a json array stored in my postgres database.
The json looks like this:</p>
<pre class="lang-none prettyprint-override"><code>[
    {
        &quot;operation&quot;: &quot;U&quot;,
        &quot;taxCode&quot;: &quot;1000&quot;,
        &quot;description&quot;: &quot;iva description&quot;,
        &quot;tax&quot;: &quot;12&quot;
    },
    {
        &quot;operation&quot;: &quot;U&quot;,
        &quot;taxCode&quot;: &quot;1001&quot;,
        &quot;description&quot;: &quot;iva description&quot;,
        &quot;tax&quot;: &quot;12&quot;
    },
    {
        &quot;operation&quot;: &quot;U&quot;,
        &quot;taxCode&quot;: &quot;1002&quot;,
        &quot;description&quot;: &quot;iva description&quot;,
        &quot;tax&quot;: &quot;12&quot;
    }
]
</code></pre>
<p>Now I need to <code>SELECT</code> the array so that any element is in a different row of the query result. So the <code>SELECT</code> statement I perform must return the data in this way:</p>
<pre class="lang-none prettyprint-override"><code> data
--------------------------------------------------------------------------------------
{ &quot;operation&quot;: &quot;U&quot;, &quot;taxCode&quot;: &quot;1000&quot;, &quot;description&quot;: &quot;iva description&quot;, &quot;tax&quot;:&quot;12&quot;}
{ &quot;operation&quot;: &quot;U&quot;, &quot;taxCode&quot;: &quot;1001&quot;, &quot;description&quot;: &quot;iva description&quot;, &quot;tax&quot;:&quot;12&quot;}
{ &quot;operation&quot;: &quot;U&quot;, &quot;taxCode&quot;: &quot;1002&quot;, &quot;description&quot;: &quot;iva description&quot;, &quot;tax&quot;:&quot;12&quot;}
</code></pre>
<p>I tried using the <code>unnest()</code> function</p>
<pre class="lang-sql prettyprint-override"><code>SELECT unnest(json_data::json)
FROM my_table
</code></pre>
<p>but it doesn't accept the <code>jsonb</code> type.</p>