title: Convert Dictionary to JSON specific format
body: <p>I have the below dictionary</p>
  
  <pre><code>{'A': ['ABC', 'DEF'],
   'B': ['GHI','JKL', 'MNO']
  }
  </code></pre>
  
  <p>And need to transform it to the below json format </p>
  
  <pre><code>{
      "type": "A",
      "keys": [
          "ABC",
          "DEF"
              ]
  }
  {
      "type": "B",
      "keys": [
          "GHI",
          "JKL",
          "MNO",
          "PQR"
              ]
  }
  </code></pre>
  
  <p>]</p>
  
  <p>I've tried  the below but it is not working as I want</p>
  
  <pre><code>with open('test.txt', 'w') as json_file:
    json.dump(final, json_file)
  </code></pre>