#NEWLINE# def write_json_lines( json_objects , filename , mode = 'wt' , encoding = None ) : #NEWLINE# #INDENT# '\n    Iterate over a stream of JSON objects, writing each to a separate line in\n    file ``filename`` but without a top-level JSON object (e.g. array).\n\n    Args:\n        json_objects (iterable(json)): sequence of valid JSON objects to be written\n        filename (str): /path/to/file on disk to which JSON objects will be written,\n            where each line in the file is its own json object; for example::\n\n                {"title": "Harrison Bergeron", "text": "The year was 2081, and everybody was finally equal."}\n\n                {"title": "2BR02B", "text": "Everything was perfectly swell."}\n\n        mode (str, optional)\n        encoding (str, optional)\n    ' #NEWLINE# _make_dirs ( filename ) #NEWLINE# with io . open ( filename , mode = mode , encoding = encoding ) as f : #NEWLINE# #INDENT# for json_object in json_objects : #NEWLINE# #INDENT# f . write ( ( json . dumps ( json_object , ensure_ascii = False ) + '\n' ) )