Issue with python JSONDecodeError

Posted by Jingbiao on July 14, 2021


Json loader issue

  • When inputting json file into python with json.loads(_),
[json.loads(jline) for jline in open(path, "r").read().split('\n')]

line 36 of

  • a likely issue may be: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

  • the reason is there might be blank line at the end of all the entries.

Simple Fixes

  • Remove all the empty lines

Alternative Fixes

Add if jline != "" into the line

[json.loads(jline) for jline in open(path, "r").read().split('\n')
 if jline != ""]