Currently, my json data is formatted as:
{"1": {"name": "camera", "aisle": "M.53", "status": "Out of Stock"}, "2": {"name": "camera", "aisle": "M.36", "status": "In Stock"}, "3": {"name": "camera", "aisle": "M.38", "status": "In Stock"}}
I would like to reformat the 'block' of data so that it prints each 'group' of data is on its on line. The data does not need to remain in json format - I simply want to break up the information into individual lines (similar to the following):
"1": {"name": "camera", "aisle": "M.53", "status": "Out of Stock"},
"2": {"name": "camera", "aisle": "M.36", "status": "In Stock"},
"3": {"name": "camera", "aisle": "M.38", "status": "In Stock"}
Here is the code I'm using:
result = json.loads(data['searchResults'])['results'][0]
summary = {
'name': result['name'],
'aisle': result['price']['aisle'][0],
'status': result['inventory']['status'],
}
results[store] = summary
with open('Testing.txt', 'w') as outfile:
outfile.write('\n')
json.dump(results, outfile)
What is a recommended way to go about adding the line breaks?