|
@@ -121,32 +121,30 @@ def loads(raw_data):
|
|
|
//
|
|
|
(.*)
|
|
|
$
|
|
|
- """, re.MULTILINE | re.VERBOSE
|
|
|
- )
|
|
|
-
|
|
|
+ """, re.MULTILINE | re.VERBOSE)
|
|
|
+
|
|
|
INLINE_COMMENT_RE = re.compile(r"""
|
|
|
- (?:[\,\"\[\]\{\}\d]) # anythig that might end a expression
|
|
|
+ ([\,\"\[\]\{\}\d]) # anythig that might end a expression
|
|
|
\s+
|
|
|
//
|
|
|
\s
|
|
|
- ([^\"\]\}\{\[]*) # the comment (except things which might be json)
|
|
|
+ (?:[^\"\]\}\{\[]*) # the comment (except things which might be json)
|
|
|
$
|
|
|
- """, re.MULTILINE | re.VERBOSE
|
|
|
- )
|
|
|
-
|
|
|
+ """, re.MULTILINE | re.VERBOSE)
|
|
|
+
|
|
|
TRAILING_COMMA_RE = re.compile(r"""
|
|
|
,
|
|
|
- \s*
|
|
|
+ (?:\s*)
|
|
|
+ $
|
|
|
+ (\s*)
|
|
|
([\]\}])
|
|
|
- """, re.MULTILINE | re.VERBOSE
|
|
|
- )
|
|
|
-
|
|
|
+ """, re.MULTILINE | re.VERBOSE)
|
|
|
if isinstance(raw_data, bytes):
|
|
|
raw_data = raw_data.decode('utf-8')
|
|
|
|
|
|
raw_data = ONELINE_COMMENT_RE.sub(r"", raw_data)
|
|
|
raw_data = INLINE_COMMENT_RE.sub(r"\1", raw_data)
|
|
|
- raw_data = TRAILING_COMMA_RE.sub(r"\1", raw_data)
|
|
|
+ raw_data = TRAILING_COMMA_RE.sub(r"\1\2", raw_data)
|
|
|
return json.loads(raw_data)
|
|
|
|
|
|
|