Commit 2a758d3d authored by Chris Lamb's avatar Chris Lamb 💬

Do some cheap fuzzy parsing to detect JSON files not named .json. (re. #888112)

parent 9bcbb517
...@@ -26,14 +26,16 @@ from .utils.file import File ...@@ -26,14 +26,16 @@ from .utils.file import File
class JSONFile(File): class JSONFile(File):
@classmethod @classmethod
def recognizes(cls, file): def recognizes(cls, file):
if not super().recognizes(file):
return False
with open(file.path) as f: with open(file.path) as f:
# Try fuzzy matching for JSON files
if not'.json') and \
file.magic_file_type.startswith('ASCII text'):
if '{' not in
return False
try: try:
file.parsed = json.load( file.parsed = json.load(
f, f,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment