explosion / srsly

🦉 Modern high-performance serialization utilities for Python (JSON, MessagePack, Pickle)
MIT License
435 stars 31 forks source link

srsly.read_json is broken #29

Closed tamuhey closed 4 years ago

tamuhey commented 4 years ago

code:

import srsly

print(srsly.read_json("foo.json"))

outputs:

Traceback (most recent call last):
  File "/tmp/foo.py", line 4, in <module>
    print(srsly.read_json("foo.json"))
  File "/Users/yohei_tamura/work/lilly/.venv/lib/python3.8/site-packages/srsly/_json_api.py", line 52, in read_json
    return ujson.load(f)
ValueError: Expected object or value

srsly version: 2.2.0 python version: 3.8.1

ines commented 4 years ago

It looks like the problem happens in ujson when it's trying to load the opened file.

In the code in your traceback, you're reading from sys.argv[0] – are you sure that points to the correct file? And that the file isn't empty and contains JSON-loadable content etc.?

tamuhey commented 4 years ago

This problem is caused because the content of my json file is broken, I'm sorry