title: JSON dumps custom formatting
body: <p>I'd like to dump a Python dictionary into a JSON file with a particular custom format. For example, the following dictionary <code>my_dict</code>,</p>
  
  <pre><code>'text_lines': [{"line1"}, {"line2"}]
  </code></pre>
  
  <p>dumped with</p>
  
  <pre><code>f.write(json.dumps(my_dict, sort_keys=True, indent=2))
  </code></pre>
  
  <p>looks like this</p>
  
  <pre><code>  "text_lines": [
      {
        "line1"
      }, 
      {
        "line2"
      }
    ]
  </code></pre>
  
  <p>while I prefer that it looks like this</p>
  
  <pre><code>  "text_lines": 
    [
      {"line1"}, 
      {"line2"}
    ]
  </code></pre>
  
  <p>Similarly, I want the following</p>
  
  <pre><code>  "location": [
      22, 
      -8
    ]
  </code></pre>
  
  <p>to look like this</p>
  
  <pre><code>  "location": [22, -8]
  </code></pre>
  
  <p>(that is, more like a coordinate, which it is).</p>
  
  <p>I know that this is a cosmetic issue, but it's important to me to preserve this formatting for easier hand editing of the file.</p>
  
  <p>Any way of doing this kind of customisation? An explained example would be great (the docs did not get me very far).</p>