A partner drops a JSON Lines feed every hour: one JSON object per line. Some lines arrive broken. Write parse_jsonl(text) that returns a tuple (records, bad_lines):
- •
records — every line that parses as a JSON object, as a dict, in order; - •
bad_lines — the 1-based line numbers of the lines that don't, in order.
A line is bad when it isn't valid JSON, or when it is valid JSON but not an object (an array, a number, a string, null). Blank lines — empty or only whitespace — are skipped: they are neither records nor bad, but they still count when numbering lines. Lines may end in \n or \r\n.
Python 3.13 in your browser — the standard library plus pandas and numpy; no pip installs.