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, 886 Views

Hey! I had the same issue with json read from file python. Turns out, the file wasn't actually in UTF-8 encoding. Try adding `encoding='utf-8'` to your `open()` call, like:

```python
with open('file.json', 'r', encoding='utf-8') as f:
data = json.load(f)
```

If that doesn’t work, maybe your JSON is malformed? Try pasting it into [JSONLint](https://jsonlint.com/) to check.

Messages In This Thread



Users browsing this thread: 1 Guest(s)