title: Python ValueError: No JSON Object Could Be Decoded (Intermittent)
body: <p>Getting an error with the following code. However, sometimes it works and sometimes it doesn't. I have validated the data with JSONLint. I have tried to decode/encode the data based off responses to similar error questions and also tried the same using the codecs module. What I don't understand is why it sometimes works fine and then other times throws an error. </p>
  
  <pre><code>import requests
  import json
  import codecs
  
  response = requests.get("https://api.weather.gov/alerts/active")
  print(response.status_code)
  
  with open ('data.json', 'w') as file:
      file.write(response.content)
  
  myFile = open('data.json', 'r')
  myObject = myFile.read()
  u = myObject.decode('utf-8-sig')
  myObject = u.encode('utf-8')
  myFile.encoding
  myFile.close()
  myData = json.loads(myObject, 'utf-8') 
  
  #myData=json.loads(codecs.open(myObject,'r', 'utf-8'))
  </code></pre>
  
  <p>A sample of the JSON data can be found in another question I asked <a href="https://stackoverflow.com/questions/50028427/access-field-in-json-data/">here</a>.</p>