"Python read in json file – what’s the simplest method?"
Hey folks! So I’ve been messing around with python read in json file stuff, and honestly, it’s kinda confusing at first. Like, there’s a bunch of ways to do it, but which one’s the *easiest*?
I’ve seen people use `json.load()` with files, and `json.loads()` for strings, but tbh, `json.load()` is the way to go if you’re just reading from a file, right?
```python
import json
with open('data.json', 'r') as f:
data = json.load(f)
```
Boom, done. Or am I missing something?
Also, why do some folks use `pathlib` instead of `open()`? Overkill or actually better?
Would love to hear how y’all handle python read in json file tasks!
Hey folks! So I’ve been messing around with python read in json file stuff, and honestly, it’s kinda confusing at first. Like, there’s a bunch of ways to do it, but which one’s the *easiest*?
I’ve seen people use `json.load()` with files, and `json.loads()` for strings, but tbh, `json.load()` is the way to go if you’re just reading from a file, right?
```python
import json
with open('data.json', 'r') as f:
data = json.load(f)
```
Boom, done. Or am I missing something?
Also, why do some folks use `pathlib` instead of `open()`? Overkill or actually better?
Would love to hear how y’all handle python read in json file tasks!
