title: How do I write JSON data to a file?
body: <p>How do I write JSON data stored in the dictionary <code>data</code> to a file?</p>
  <pre><code>f = open('data.json', 'wb')
  f.write(data)
  </code></pre>
  <p>This gives the error:</p>
  <blockquote>
  <p>TypeError: must be string or buffer, not dict</p>
  </blockquote>