namedtupled icon indicating copy to clipboard operation
namedtupled copied to clipboard

Error Json(path="object.json") : AttributeError: 'str' object has no attribute 'read'

Open limsan opened this issue 8 years ago • 2 comments

Traceback (most recent call last): File "testNameTupled.py", line 6, in vals = namedtupled.json(path="object.json") File "C:\Users\PERKASA\AppData\Local\conda\conda\envs\python2\lib\site-packages\namedtupled\integrations.py", line 19, in load_json return mapper(json.load(path), nt_name=name) File "C:\Users\PERKASA\AppData\Local\conda\conda\envs\python2\lib\json_init.py", line 287, in load return loads(fp.read(), AttributeError: 'str' object has no attribute 'read'

limsan avatar Nov 04 '17 02:11 limsan

@limsan the confusion, I think, is that the path parameter (in the definition of namedtupled.json) is misnamed. In practice, it is actually meant to be file-like argument of the same type expected by json.load() rather than the name of file as per your (reasonable) expectation.

jonseymour avatar Nov 08 '17 12:11 jonseymour

Looking back at this again, sorry I'm still thinking about the best way forward

brennv avatar Feb 14 '18 20:02 brennv