Your input appears to be a sequence of Python objects; it certainly is not valid a JSON document.

If you have a list of Python dictionaries, then all you have to do is dump each entry into a file separately, followed by a newline:

import json

with open('output.jsonl', 'w') as outfile:
    for entry in JSON_file:
        json.dump(entry, outfile)
        outfile.write('\n')

The default configuration for the json module is to output JSON without newlines embedded.

Assuming your A, B and C names are really strings, that would produce:

{"index": 1, "met": "1043205", "no": "A"}
{"index": 2, "met": "000031043206", "no": "B"}
{"index": 3, "met": "0031043207", "no": "C"}

If you started with a JSON document containing a list of entries, just parse that document first with json.load()/json.loads().

Answer from Martijn Pieters on Stack Overflow
๐ŸŒ
Medium
galea.medium.com โ€บ how-to-love-jsonl-using-json-line-format-in-your-workflow-b6884f65175b
How to Love jsonl โ€” using JSON Lines in your Workflow | by Alexander Galea | Medium
April 9, 2024 - I use jsonl for dumping raw โ€œsource of truthโ€ data. From there it can be loaded in and processed by any part of the application and, if needed, dumped into a relational format (e.g. Postgres, MySQL, CSV). Here are python functions that can be used to write and read jsonl:
๐ŸŒ
Readthedocs
jsonlines.readthedocs.io
jsonlines โ€” jsonlines documentation
The sort_keys argument can be used to sort keys in json objects, and will produce deterministic output. For more control, provide a a custom encoder callable using the dumps argument. The callable must produce (unicode) string output. If specified, the compact and sort arguments will be ignored. When the flush argument is set to True, the writer will call fp.flush() after each written line.
Discussions

How to write each JSON objects in a newline of JSON file? (Python) - Stack Overflow
It should have [{},{}] as notation, then you have a valid json file to load. ... Sorry, it was just an example. I don't have any error. The result doesn't match my expectations. Maybe I've found , in the separators I'll put '\n'. I'll try. ... \n is indeed for line breaks. If you use windows you should use \r\n, Unix systems usually only need \n ... @RonNabuurs I use Windows, for text file I write ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
June 4, 2018
How can I write data to a json file and also write the variable name?
The resulting file you are creating here isn't a valid json document. If you printed a "\n" between each dump, it would be valid jsonl (json lines). I believe just storing one data structure instead of 3 seperate ones solves both of your issues: import json my_data = { "x": [1, 2, 3], "y": [4, 5, 6], "z": {"1": 1, "2": 2}, } with open("test.json", "a", encoding="utf-8") as f: json.dump(my_data, f) More on reddit.com
๐ŸŒ r/learnpython
8
4
August 13, 2022
There's no way to have multi-line strings in a Json file, right? How could I deal with this limitation when getting Python to read from such a file.
you can have multiline strings in json. this is the contents of sample.json {"text": "hello world\n2nd line"} and some python that reads the file import json with open("/tmp/sample.json", "rb") as f: x = json.loads(f.read()) the value of x["text"] is a multiline string. More on reddit.com
๐ŸŒ r/learnpython
9
5
September 13, 2017
JSON lines

Why not just surround the whole thing with a regular json array so the file itself is valid json? Would make parsing it much easier.

More on reddit.com
๐ŸŒ r/programming
86
101
September 26, 2015
People also ask

How do I read a JSONL file in Python?
The simplest approach uses only the Python standard library: open the file, iterate over lines, strip whitespace, skip empty lines, and call json.loads() on each line. Example: import json; records = [json.loads(line) for line in open("data.jsonl") if line.strip()]. This handles files of any size because it reads one line at a time without loading the full file. For production code, wrap json.loads() in a try/except to catch json.JSONDecodeError on malformed lines and log them without stopping processing. The jsonlines library (pip install jsonlines) provides a cleaner API with jsonlines.open(
๐ŸŒ
jsonic.io
jsonic.io โ€บ home โ€บ guides โ€บ jsonl format
JSONL Format (JSON Lines): Read, Write, and Stream Line-Delimited ...
How can I read a JSONL file in Python?
Open the file and call json.loads() on each non-empty line inside a for loop. That streams the file with constant memory, so the same loop handles gigabyte-sized datasets. For analysis, pandas.read_json with lines=True loads it into a DataFrame.
๐ŸŒ
jsonltools.com
jsonltools.com โ€บ jsonl tools โ€บ jsonl tutorial
JSONL Tutorial: Learn JSON Lines with Python Examples [2026] - ...
How do I convert a JSON array to JSONL?
The fastest one-liner uses jq: jq -c '.[] ' input.json > output.jsonl. The -c flag outputs compact (single-line) JSON; .[] iterates over array elements. In Python: import json; [open("out.jsonl","w").write(json.dumps(r)+"\n") for r in json.load(open("in.json"))]. In JavaScript: const arr = JSON.parse(fs.readFileSync("in.json","utf8")); fs.writeFileSync("out.jsonl", arr.map(r => JSON.stringify(r)).join("\n")+"\n"). To convert JSONL back to a JSON array, use jq with slurp mode: jq -s "." input.jsonl > output.json. The -s flag reads all lines and collects them into an array. Note that co
๐ŸŒ
jsonic.io
jsonic.io โ€บ home โ€บ guides โ€บ jsonl format
JSONL Format (JSON Lines): Read, Write, and Stream Line-Delimited ...
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ json-lines
json-lines ยท PyPI
JSON lines is a text file format where each line is a single json encoded item.
      ยป pip install json-lines
    
Published: Nov 21, 2018
Version: 0.5.0
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
JSON encoder and decoder โ€” Python 3.14.7 documentation
Encode the given object, o, and yield each string representation as available. For example: for chunk in json.JSONEncoder().iterencode(bigobject): mysocket.write(chunk) ... The JSON document being parsed.
๐ŸŒ
GitHub
github.com โ€บ rmoralespp โ€บ jsonl
GitHub - rmoralespp/jsonl: Zero-dependency Python library for JSON Lines โ€” read, write, compress, and stream in one line of code.
Installing the package also provides the jsonl command (equivalently python -m jsonl): ... INFILE may be a JSON Lines file, a ZIP/TAR archive, a URL, or - for stdin. When OUTFILE is omitted, output is written to stdout.
Author: rmoralespp
Find elsewhere
๐ŸŒ
Jsonic
jsonic.io โ€บ home โ€บ guides โ€บ jsonl format
JSONL Format (JSON Lines): Read, Write, and Stream Line-Delimited JSON โ€” Jsonic
May 12, 2026 - The standard library approach requires no dependencies and works for files of any size: open the file, iterate over lines, strip whitespace, skip empty lines, and pass each line to json.loads(). The jsonlines library provides a cleaner API and handles edge cases (BOM, trailing whitespace) automatically. Choose the approach that fits your environment; the performance difference is negligible for most workloads. import json # Plain Python โ€” no library needed with open('data.jsonl', 'r') as f: for line in f: line = line.strip() if not line: continue record = json.loads(line) print(record) # With jsonlines library (pip install jsonlines) import jsonlines with jsonlines.open('data.jsonl') as reader: for record in reader: print(record)
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ python-write-json-to-file
Python Guide: How to Write JSON to a File
February 1, 2024 - In this example, the json.dump() function serializes the data dictionary as a JSON formatted stream and writes it to โ€˜data.jsonโ€™. The with statement ensures that the file is properly closed after it is no longer needed. And there you have it โ€“ a basic guide to writing JSON data to a file in Python using the json.dump() function.
๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to read and write json files in python
How to Read and Write JSON Files in Python
January 25, 2026 - Notice that JSON's true becomes Python's True, and null becomes None. To write Python data to a JSON file, use json.dump():
๐ŸŒ
JSONL Tools
jsonltools.com โ€บ jsonl tools โ€บ jsonl tutorial
JSONL Tutorial: Learn JSON Lines with Python Examples [2026] - JSONL Tools
APIs that return large result sets stream NDJSON so clients process rows as they arrive instead of waiting for one giant array. Inspect any response with our JSONL viewer. ... curl -N https://api.example.com/events | while read -r line; do echo "$line" | python3 -c "import json,sys; print(json.load(sys.stdin)['id'])" done
๐ŸŒ
JSON Lint
jsonlint.com โ€บ learn โ€บ json lines (jsonl) and ndjson: format, examples, and use cases
JSON Lines (JSONL) and NDJSON: Format, Examples, and Use Cases | JSONLint
August 14, 2026 - Python can process the file one ... print(f"Line {line_number}: {error}") Write compact records with one json.dumps() call per line: import json records = [{"id": 1}, {"id": 2}] with open("records.jsonl", "w", encoding="utf-8") as output: for record in records: output.write(...
๐ŸŒ
Ml-gis-service
ml-gis-service.com โ€บ index.php โ€บ 2022 โ€บ 04 โ€บ 27 โ€บ toolbox-python-list-of-dicts-to-jsonl-json-lines
Toolbox: Python List of Dicts to JSONL (json lines) โ€“ Sp.4ML
April 27, 2022 - """ sjsonl = '.jsonl' sgz = '.gz' # Check filename if not filename.endswith(sjsonl): filename = filename + sjsonl # Save data if compress: filename = filename + sgz with gzip.open(filename, 'w') as compressed: for ddict in data: jout = json.dumps(ddict) + '\n' jout = jout.encode('utf-8') compressed.write(jout) else: with open(filename, 'w') as out: for ddict in data: jout = json.dumps(ddict) + '\n' out.write(jout)
๐ŸŒ
JSON Lint
jsonlint.com โ€บ learn โ€บ read and write json files in python: load, loads, dump, and dumps
Read and Write JSON Files in Python: load, loads, dump, and dumps | JSONLint
August 14, 2026 - Read, write, parse, and serialize JSON in Python with json.load, loads, dump, and dumps, plus error handling and practical file examples.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_json.asp
Python JSON
Convert a Python object containing all the legal data types: import json x = { "name": "John", "age": 30, "married": True, "divorced": False, "children": ("Ann","Billy"), "pets": None, "cars": [ {"model": "BMW 230", "mpg": 27.5}, {"model": "Ford Edge", "mpg": 24.1} ] } print(json.dumps(x)) Try it Yourself ยป ยท The example above prints a JSON string, but it is not very easy to read, with no indentations and line breaks.
๐ŸŒ
Rowzero
rowzero.com โ€บ blog โ€บ open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format - Row Zero โ€“ the spreadsheet for modern cloud data
March 10, 2026 - Here's example code: import jsonlines data = [{"name": "John", "age": 30}, {"name": "Anna", "age": 22}] with jsonlines.open('output.jsonl', mode='w') as writer: writer.write_all(data) You can convert a JSON file to JSONL format in Python by ...
๐ŸŒ
Medium
nicholaszhan.com โ€บ line-em-up-a-guide-to-json-lines-7c43215b3b82
Line โ€™Em Up: A Guide to JSON Lines | by Nicholas Zhan | Medium
February 2, 2024 - Large data sets can stretch the capabilities of standard data formats to their limits. JSON Lines excels in scalability because it facilitates incremental data writes. You do not need to re-write the entire file when adding new records; instead, you can append new data as a new line at the end of the file.
Starred by 305 users
Forked by 31 users
Languages: Python
๐ŸŒ
Medium
medium.com โ€บ @caseyahenson โ€บ quick-tip-writing-newline-character-to-json-file-in-python-3705a2cd14fb
Quick Tip: Writing newline character to JSON file in Python | by Casey Henson | Medium
January 8, 2022 - Now you have an invalid JSON string. Letโ€™s fix it. One way to prevent Python from interpreting the newline characters and placing line returns within your file is to use a simple hack. First define a variable that looks similar to your newline string but instead of the letter โ€œnโ€, you use something like a capital โ€œXโ€. ... Awesome, so Python doesnโ€™t see this as anything other than a string.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ json
Python JSON: Read, Write, Parse JSON (With Examples)
Here's a table showing Python objects and their equivalent conversion to JSON. To write JSON to a file in Python, we can use json.dump() method.