Say I want to dump multiple variables to disk with Json. They way I usually do this is by creating my variables as entries in a dictionary and then dumping the dictionary to disk:
with open(p_out, 'wb') as fp:
json.dump(my_dictionary, fp)
This creates a json file where the dictionary is saved in a long line:
{"variable_1": something, "variable_2" something_else, ...}
which I don't like. I would prefer to have my variables dumped into the text file with one variable per line, e.g something along these lines:
{variable_1: something\n
variable_2: something\n
variable_3: something_else}
Is there a way to do this with Json in Python?
{'variable_1': 'something'}, would you want the output file to contain"variable_1": "something"orvariable_1: something. Without the quotes it is not JSON.