How to put JSON data into a dictionary Python – what's the best way? or Struggling with how to put JS

14 Replies, 1377 Views

man, i remember being confused about this too! for how to put json data into a dictionary python, json.loads() is your friend for strings.

but if it’s from a file, you gotta open it first. here’s how:

```python
import json

with open('stuff.json') as f:
data = json.load(f)
```

also, if your json is messy, try https://jsonlint.com/ to clean it up first.

Messages In This Thread



Users browsing this thread: 1 Guest(s)