We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ae96b6c + e9f1b91 commit 500fc85Copy full SHA for 500fc85
1 file changed
minify_json.py
@@ -16,6 +16,8 @@
16
17
def json_minify(string, strip_space=True):
18
tokenizer = re.compile('"|(/\*)|(\*/)|(//)|\n|\r')
19
+ end_slashes_re = re.compile(r'(\\)*$')
20
+
21
in_string = False
22
in_multi = False
23
in_single = False
@@ -36,7 +38,7 @@ def json_minify(string, strip_space=True):
36
38
val = match.group()
37
39
40
if val == '"' and not (in_multi or in_single):
- escaped = re.search(r'(\\)*$', string[:match.start()])
41
+ escaped = end_slashes_re.search(string, 0, match.start())
42
43
# start of string or unescaped quote character to end string
44
if not in_string or (escaped is None or len(escaped.group()) % 2 == 0):
0 commit comments