title: TypeError: Object of type function is not JSON serializable
body: <p>I currently struggle to understand why the following code is not working:</p>
  
  <pre><code>import json
  import random
  
  def _time_series_prc(start_date, count, periodicity, is_history=True):
      values = []
  
      print(type(start_date))
      print(type(periodicity))
  
      for i in range(count - 1):
          value = random.uniform(0, 1)
          values.append(value)
  
      return _build_series(values, start_date, periodicity, is_history)
  
  
  def _build_series(values, start_date, periodicity, is_history):
      if is_history:
          values.reverse()
  
      return {
          'periodicity': periodicity,
          'startDate': start_date,
          'values': values,
      }
  
  result = _time_series_prc('2019-07-17', 52, 'WEEKLY')
  
  print(json.dumps(result, indent=4));
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>&lt;class 'str'&gt;
  &lt;class 'str'&gt;
  TypeError: Object of type function is not JSON serializable
  </code></pre>
  
  <p>At line 7, the <code>json.dumps</code> I get the error: TypeError: Object of type function is not JSON serializable`. Im not using ptyhon very long But I cant understand how this can be a function pointer instead of the returned value.</p>