Okay, I have been running around in circles. I have a list of dictionaries I am trying to serialize to a JSON file. I am using:
with open('/file_path/test.json', 'w') as write_file:
json.dump(rdf_dic, write_file, separators = (',\n', ':'))
This works fine but my output looks like:
[ {"field_1":"1",
"error_id":2,
"another_feature":"yes"},
{"field_1":"1",
"error_id":2,
"another_feature":"yes"},
{"field_1":"no",
"error_id":2,
"another_feature":"ugh"}
]
etc. etc. for ~27k records.
However, I need each dictionary to exist on one line only. I know it sounds bizarre, but this file is being submitted and those are the requirements. I have searched high and low and truly am at a loss.
As a bonus, I also need the commas separating each record to not be there.
I also try:
with open('/file_path/test.json', 'w') as write_file:
for record in rdf_dic:
json.dump(record, write_file, separators = (',\n', ':'))
and receive almost identical results (just without the dictionaries being wrapped in a list).
ANY help would be greatly appreciated.