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

14 Replies, 1299 Views

json into a dict? no sweat! for how to put json data into a dictionary python, just use json.loads() if it’s a string.

for files:
```python
import json

data = json.load(open('file.json'))
```

but tbh, using `with` is safer (like others said).

ps. if you’re getting errors, maybe your json is malformed. double-check it!

Messages In This Thread



Users browsing this thread: 1 Guest(s)