title: TypeError: Object of type filter is not JSON serializable - Nested Object
body: <pre><code>import csv
  import json 
  
  def csv_to_json(csvFilePath):
      jsonArray = []
      
      decoded_file = csvFilePath.read().decode('utf-8').splitlines()
     
      #load csv file data using csv library's dictionary reader
      csvReader = csv.DictReader(decoded_file) 
      #convert each csv row into python dict
      for row in csvReader: 
          #add this python dict to json array
          option = [row['option1'], row['option2'], row['option3'], row['option4']]
          option = filter(None, option)
          newJson = {
            'numb': row['numb'],
            'question': row['question'],
            'answer': row['answer'],
            'options': option
          }
          jsonArray.append(newJson)
  
      print('&gt;&gt;&gt;&gt;&gt;&gt;&gt;jsonArray&gt;&gt;&gt;&gt;&gt;&gt;&gt;', jsonArray)
  
      jsonString = json.dumps(jsonArray)
  
      print('&gt;&gt;&gt;&gt;&gt;&gt;&gt;jsonString&gt;&gt;&gt;&gt;&gt;&gt;&gt;', jsonString)
  
      return jsonArray
  </code></pre>
  <p>Error</p>
  <pre><code>TypeError at /path/path
  Object of type filter is not JSON serializable
  
  &gt;&gt;&gt;&gt;&gt;&gt;&gt;jsonArray&gt;&gt;&gt;&gt;&gt;&gt;&gt; [{'numb': '1', 'question': 'What does HTML stand for?', 'answer': 'Hyper Text Markup Language', 'options': &lt;filter object at 0x7f3d3459fa00&gt;}, {'numb': '2', 'question': 'What does CSS stand for?', 'answer': 'Cascading Style Sheet', 'options': &lt;filter object at 0x7f3d34317400&gt;}]
  
  </code></pre>
  <p>If i comment out <code># 'options': option</code> from <code>newJson</code> then it works perfectly</p>