Python ValueError: No JSON object could be decoded


It’s possible the .read() method is moving the cursor to the end of the file. Try:

for filename in filenames:
    with open(os.path.join(dirname,filename)) as fd:
        json_data = json.load(fd)

and see where that gets you.

This, of course, assumes you have valid JSON, as your example demonstrates. (Look out for trailing commas)

Leave a Comment