title: Write JSON to a file in pretty print format in Django
body: <p>I need to create some JSON files for exporting data from a Django system to Google Big Query.</p>
  <p>The problem is that Google BQ imposes some characteristics in the JSON file, for example, that each object must be in a different line.</p>
  <p>json.dumps writes a stringified version of the JSON, so it is not useful for me.</p>
  <p>Django serializes writes better JSON, but it put all in one line. All the information I found about pretty-printing is about json.dumps, which I cannot use.</p>
  <p>I will like to know if anyone knows a way to create a JSON file in the format required by Big Query.</p>
  <p>Example:</p>
  <pre><code>    JSONSerializer = serializers.get_serializer(&quot;json&quot;)
      json_serializer = JSONSerializer()
      data_objects = DataObject.objects.all()
      with open(&quot;dataobjects.json&quot;, &quot;w&quot;) as out:
          json_serializer.serialize(data_objects, stream=out)
  </code></pre>