code: def parse_json(json_file, include_date=False):
      
      if json_file[-2:] == 'gz':
          fh = gzip.open(json_file, 'rt')
      else:
          fh = io.open(json_file, mode='rt', encoding='utf8')
      for line in fh:
          try:
              jj = json.loads(line)
              if type(jj) is not list:
                  jj = [jj]
              for j in jj:
                  if include_date:
                      yield (j['user']['screen_name'].lower(), j['text'], j['created_at'])
                  else:
                      if 'full_text' in j: # get untruncated text if available.
                          yield (j['user']['screen_name'].lower(), j['full_text'])
                      else:
                          yield (j['user']['screen_name'].lower(), j['text'])
  
          except Exception as e:
              sys.stderr.write('skipping json error: %s\n' % e)
docs: Yield screen_name, text tuples from a json file.