Skip to content
Advertisement

How might I output an array of dictionaries on different lines on a JSON file?

JavaScript

I have gotten this output which is an array of dictionaries which was what I wanted

JavaScript

that I want to upload to a JSON file using this function:

JavaScript

I can already upload it to the JSON file. My question is how might I be able to upload this array to the JSON file where each dictionary in the curly brackes are printed onto different lines like this:

JavaScript

I have tried using the indent function but it produces this output.

JavaScript

Can someone please explain to me what I am doing wrong and how I may fix this problem?

Advertisement

Answer

You can do something like

JavaScript

then lines should contain the data formatted in the way you want

out.json after running the above:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement