JSONDecodeError in Lesson 3

Here is the code block…

import json
from pygments import highlight, lexers, formatters

# parse JSON
parsed_json = json.loads(data.replace("'", '"'))

# pretty print JSON with syntax highlighting
formatted_json = json.dumps(parsed_json, indent=4)
colorful_json = highlight(formatted_json,


How do I resolve this error?

JSONDecodeError                           Traceback (most recent call last)
Cell In[14], line 5
      2 from pygments import highlight, lexers, formatters
      4 # parse JSON
----> 5 parsed_json = json.loads(data.replace("'", '"'))
      7 # pretty print JSON with syntax highlighting
      8 formatted_json = json.dumps(parsed_json, indent=4)

File /usr/local/lib/python3.11/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    341     s = s.decode(detect_encoding(s), 'surrogatepass')
    343 if (cls is None and object_hook is None and
    344         parse_int is None and parse_float is None and
    345         parse_constant is None and object_pairs_hook is None and not kw):
--> 346     return _default_decoder.decode(s)
    347 if cls is None:
    348     cls = JSONDecoder

File /usr/local/lib/python3.11/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
    332 def decode(self, s, _w=WHITESPACE.match):
    333     """Return the Python representation of ``s`` (a ``str`` instance
    334     containing a JSON document).
    336     """
--> 337     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338     end = _w(s, end).end()
    339     if end != len(s):

File /usr/local/lib/python3.11/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
    353     obj, end = self.scan_once(s, idx)
    354 except StopIteration as err:
--> 355     raise JSONDecodeError("Expecting value", s, err.value) from None
    356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

did you download all the files from the File===Open option??

I am following along using the course-supplied jupyter notebook and environment. All the cells before this worked without error. I am looking back now at the previous cells to see if I missed a step … however, I do not think I did.

if you go through your error, you will see with the parsed code, the exception thrown as error is because it is not able to find the file in your system. Hence the error.

Kindly use the short course FAQ to know how to download all the files to run in your local system.

otherwise, Click File===Open, you will find a list of files required you to download and then locate all these file in one folder with the assignment file you are working.


OK … thanks for your assistance.