The code uses json as the name of the variable. It obscures the link to the module you imported. Use a different name for the variable.
In addition, the code passes the file object, and json.loads takes the string.
Transfer the contents of the file:
json_data = json.loads(json_file.read())
or use json.load , which accepts a file-like object.
json_data = json.load(json_file)
source share