title: How can I write to JSON file, without deleting all the content in it?
body: <pre><code>import json
  f = open(&quot;filename.json&quot;, &quot;w&quot;)
  data = {&quot;username&quot;: &quot;justausername&quot;}
  json.dump(data, f)
  </code></pre>
  <p>When I run this code, all the data in the &quot;filename.json&quot; is replaced by &quot;{'username': 'justausername'}&quot;. Please help!</p>