title: Displaying better error message than "No JSON object could be decoded"
body: <p>Python code to load data from some long complicated JSON file:</p>
  
  <pre><code>with open(filename, "r") as f:
    data = json.loads(f.read())
  </code></pre>
  
  <p>(note: the best code version should be:</p>
  
  <pre><code>with open(filename, "r") as f:
    data = json.load(f)
  </code></pre>
  
  <p>but both exhibit similar behavior)</p>
  
  <p>For many types of JSON error (missing delimiters, incorrect backslashes in strings, etc), this prints a nice helpful message containing the line and column number where the JSON error was found.</p>
  
  <p>However, for other types of JSON error (including the classic "using comma on the last item in a list", but also other things like capitalising true/false), Python's output is just:</p>
  
  <pre><code>Traceback (most recent call last):
    File "myfile.py", line 8, in myfunction
      config = json.loads(f.read())
    File "c:\python27\lib\json\__init__.py", line 326, in loads
      return _default_decoder.decode(s)
    File "c:\python27\lib\json\decoder.py", line 360, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "c:\python27\lib\json\decoder.py", line 378, in raw_decode
      raise ValueError("No JSON object could be decoded")
  ValueError: No JSON object could be decoded
  </code></pre>
  
  <p>For that type of ValueError, how do you get Python to tell you where is the error in the JSON file?</p>