0

I'm trying to read in and parse a json file, I'm not sure why I'm getting this error. I had this working earlier today but after I updated and restarted Spyder it wouldn't work. I've now tried it with vscode as well and am running into the same error.

with open(r"C:\Users\Eric\OneDrive\GUI Proj\NBA_schedule.json") as myfile:
    data = myfile.read()
sched_access = data['leagueSchedule']
gameDates = sched_access['gameDates']

I got this json file from this link https://cdn.nba.com/static/json/staticData/scheduleLeagueV2.json and have tried both json.load() and json.loads() as well as not using the with open method. But I am continuing to get errors. What am I missing here?

EDIT: It has to do with one of my imports...somehow

2

1 Answer 1

0

For me is working this example with the same json file that I have downloaded (copied in a local file)

import json

with open('1.json') as json_file:
    data = json.load(json_file)
    
season = data['leagueSchedule']['seasonYear']
league = data['leagueSchedule']['leagueId']

print(season)
print(league)

Output:

2021-22
00
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.