What's the best way to read JSON from a file in Python? or How do I properly read JSON from a file in

18 Replies, 913 Views

If json read from file python is giving you grief, try this:

```python
import json
with open('file.json', 'r') as f:
try:
data = json.load(f)
print(data) # See if it looks right
except Exception as e:
print(f"Oops: {e}")
```

Also, maybe share a snippet of your JSON? Could be something tiny breaking it.

Messages In This Thread



Users browsing this thread: 1 Guest(s)