Parse two JSON objects
Input
parse_json_lines('{"a": 1}\n{"b": 2}')
Output
[{'a': 1}, {'b': 2}]
Two JSON objects are parsed into a list of dictionaries.
Full lesson preview
Parse newline-delimited JSON (JSON Lines) into Python records, skipping bad lines and optionally extracting keys.
Problem statement
Task
Examples
Input
parse_json_lines('{"a": 1}\n{"b": 2}')
Output
[{'a': 1}, {'b': 2}]
Two JSON objects are parsed into a list of dictionaries.
Input
parse_json_lines('{"a":1,"b":2}\n{"a":3}', ['a','b'])
Output
[(1, 2), (3, None)]
When keys are provided, return tuples of values; missing keys yield None.
Input format
Output format
Constraints
Samples
Input
parse_json_lines('{"x": {"y": 5}, "z": 1}\n{"x": {"y": 6}}', ['x','z'])
Output
[({'y': 5}, 1), ({'y': 6}, None)]
Nested dicts are preserved and missing keys become None.