title: How to combine each element within a JSON list to each other
body: <p>I have a JSON object like this:</p>
  <pre><code>{ school: [
    {
     &quot;teacher&quot;: [
                  &quot;Ms. Brown&quot;,
                  &quot;Mr. Schmidt&quot;
              ],
     &quot;student&quot;: [
                  &quot;H. Cosby&quot;,
                  &quot;L. Watson&quot;
              ]
    },
    {
     &quot;teacher&quot;: [
                  &quot;Mr. Port&quot;,
              ],
     &quot;student&quot;: [
                  &quot;M. John&quot;,
                  &quot;A. Reilly&quot;
              ]
    }
   ]
  }
  </code></pre>
  <p>And I want to combine each element within an element with each other so like this:</p>
  <p><code>[Ms. Brown, H. Cosby], [Ms. Brown, L. Watson], [Mr. Schmidt, H. Cosby], [Mr, Schmidt, L.Watson], [Mr. Port, M. John], [Mr. Port, A. Reilly]</code></p>
  <p>I'm using Jinja2 and I can't separate the object into two. I managed with a for-loop, but that only outputs it like this:</p>
  <p><code>teacher:&quot;Ms. Brown&quot;, &quot;Mr. Schmidt&quot; student:&quot;H. Cosby&quot;, &quot;L. Watson&quot;</code></p>
  <p>which isn't what I'm looking for</p>
  <p>[Edit:] Anyways found a solution. I just used</p>
  <p><code>{{ item.teacher | product(item.student) | map('join', ', ') | join(', ') }}</code></p>
  <p>within a for-loop. The solution seems easier than I thought lol.</p>