sheetbot / utils.py
linpershey's picture
add missing data workflow
948e91c
raw
history blame
392 Bytes
import re
import json
def parse_json_garbage(s):
s = s[next(idx for idx, c in enumerate(s) if c in "{["):]
print(s)
s = s[:next(idx for idx, c in enumerate(s) if c in "}]")+1]
print(s)
try:
return json.loads(re.sub("[//#].*","",s,flags=re.MULTILINE))
except json.JSONDecodeError as e:
return json.loads(re.sub("[//#].*","",s,flags=re.MULTILINE))