title: Writing list of objects to JSON file
body: <p>As part of my homework I have to make a JSON file with class objects in it. I could do it, but the result is not that i expected. </p>
  
  <pre><code>import json    
  stList = []
  
  
  class Student(object):
      neptun_code = ""
      result = 0
      mark = 0
  
  
  def make_student(neptun_code, result, mark):
      student = Student()
      student.neptun_code = neptun_code
      student.result = result
      student.mark = mark
  
      stList.append(student)
  
  
  def create_json():
      json_string = json.dumps([ob.__dict__ for ob in stList])
      with open("./data/student.txt", "w") as file:
          json.dump(json_string, file)
  </code></pre>
  
  <p>Sample inputs for <code>make_student</code> : <em>test_code, test_result, test_mark</em></p>
  
  <p>Here is the output in student.txt:</p>
  
  <pre><code> "[{\"neptun_code\": \"test_code\", \"result\": \"test_result\", \"mark\": \"test_mark\"}]"
  </code></pre>
  
  <p>there are plenty of unwanted characters in it. <strong>I would like to have something like this:</strong></p>
  
  <pre><code>[{"neptun_code": "test_code", "result": "test_result", "mark": "test_mark"}]
  </code></pre>
  
  <p>Can anyone explain how to do this?</p>