I have a dictionary with (string, list)
as key-value pair (list may be empty), which I write to file using:
with open(out_file, "w") as f:
json.dump(data, f, indent=4)
If I don't use indent=4
, everything is in the same line.
Problem: Output is like
{
"key_1": [
1,
2,
],
"key_2": []
}
while I wanted (mainly because the lists usually have around 10 numbers only, and easier to view on same line):
{
"key_1": [1, 2],
"key_2": []
}
Any idea have I can achieve this?