title: Python JSON-file-reading generator (multi-line)
body: <p>I have a bunch of json files with multiple lines who look like this:</p>
  
  <p>file1</p>
  
  <pre><code>{"id":1,"name":"Eric","height":1.80, ...},
  {"id":2,"name":"Bob","height":1.90, ...}   
  ...
  </code></pre>
  
  <p>file2</p>
  
  <pre><code>{"id":3,"name":"Jenny","height":1.50, ...},
  {"id":4,"name":"Marlene","height":1.60, ...} 
  ...
  
  </code></pre>
  
  <p>I want to build a generator to yield each line as a dictionary. My current code:</p>
  
  <pre><code>from typing import Iterator, Dict, Any, Optional
  import io
  import os
  
  def json_gen2(file_list: list) -&gt; Iterator[Dict[str, Any]]:
      import json
      for file in file_list:    
          with open(file) as json_file: 
              data = []
              for line in json_file:
                  data = json.load(line)
                  if not data:
                      break
                  yield data
  
  datapath = os.path.normcase(os.getcwd()) + '/data/log_data'
  file_list = get_files(datapath) # create path list of json files
  jsonfile = json_gen2(file_list)
  next(jsonfile)    
  
  </code></pre>
  
  <p>i get the following 
  <a href="https://i.stack.imgur.com/cx2On.png" rel="nofollow noreferrer">Error Message</a></p>
  
  <p>pls help :)</p>