def dicts_from_lines(lines):
lines = iter(lines)<EOL>for line in lines:<EOL><INDENT>line = line.strip()<EOL>if not line:<EOL><INDENT>continue  <EOL><DEDENT>try:<EOL><INDENT>yield json.loads(line, object_pairs_hook=OrderedDict)<EOL><DEDENT>except json.decoder.JSONDecodeError:<EOL><INDENT>content = line + '<STR_LIT>'.join(lines)<EOL>dicts = json.loads(content, object_pairs_hook=OrderedDict)<EOL>if isinstance(dicts, list):<EOL><INDENT>yield from dicts<EOL><DEDENT>else:<EOL><INDENT>yield dicts<EOL><DEDENT><DEDENT><DEDENT>
returns a generator producing dicts from json lines

    1 JSON object per line is supported:

        {"name": "n1"}
        {"name": "n2"}

    Or 1 JSON object:

        {
            "name": "n1"
        }

    Or a list of JSON objects:

        [
            {"name": "n1"},
            {"name": "n2"},
        ]