File size: 220 Bytes
60274d1
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
import json

def parse_json_garbage(s):
    s = s[next(idx for idx, c in enumerate(s) if c in "{["):]
    try:
        return json.loads(s)
    except json.JSONDecodeError as e:
        return json.loads(s[:e.pos])