Skip to content

Commit c7a8759

Browse files
author
Harry
committed
feat: add parser for JSON with JS comment
1 parent 0648f1a commit c7a8759

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

extruct/jsonld.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
JSON-LD extractor
44
"""
5-
5+
import jstyleson
66
import json
77
import re
88

@@ -34,7 +34,7 @@ def _extract_items(self, node):
3434
data = json.loads(script, strict=False)
3535
except ValueError:
3636
# sometimes JSON-decoding errors are due to leading HTML or JavaScript comments
37-
data = json.loads(
37+
data = jstyleson.loads(
3838
HTML_OR_JS_COMMENTLINE.sub('', script), strict=False)
3939
if isinstance(data, list):
4040
return data

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ mf2py>=1.1.0
88
six>=1.11
99
w3lib
1010
html-text
11+
jstyleson

0 commit comments

Comments
 (0)