title: How to format JSON data when writing to a file
body: <p>I'm trying to get this api request and have it formatted when I dump it into the JSON file. Whenever I do, its all one string and very hard to read. I've tried adding the indent but it didn't do anything. I can provide the API key if needed. </p>
  
  <pre><code>import json, requests
  
  url = "http://api.openweathermap.org/data/2.5/forecast/city?id=524901&amp;APPID={APIKEY}"
  response = requests.get(url)
  response.raise_for_status()
  
  with open('weather.json', 'w') as outfile:
       json.dump(response.text, outfile, indent=4)
  </code></pre>