0

I have a nested JSON file structured as well:

{"0": {"mean": -0.012, "std": 0.79}, "1": {"mean": 0.31, "std": 0.45}}

I tried to load and print the first value using:

val_dict = json.loads('distribution.json')
print(val_dict['0'])

But I get the error:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

How can I solve it? Do I need to parse it in another way?

Fabio
  • 613
  • 3
  • 12
  • ``json.loads`` loads from a *string*. It doesn't treat ``'distribution.json'`` as a *path to a* JSON, but directly as a JSON. – MisterMiyagi Nov 14 '21 at 08:54

0 Answers0