Skip to content

Commit 716860e

Browse files
authored
Added support for JSON with comments
1 parent 7130d9a commit 716860e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

.github/validate_mod_json.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import json
1+
import jstyleson
22
import glob
33
import os
44
import sys
@@ -12,21 +12,29 @@
1212
if filename not in ignore:
1313
print(f"Opening: {filename}")
1414
filecontent = open(filename, "r").read()
15-
modlist = json.loads(filecontent)
15+
16+
try:
17+
modlist = jstyleson.loads(filecontent)
18+
except Exception as err:
19+
error = True
20+
print(f"❌ Error reading JSON file {filename}: {err}")
21+
continue
22+
1623
for mod, data in modlist.items():
1724
url = data["mod"].replace(" ", "%20")
1825
print(f"{mod}: {url}")
1926
try:
2027
response = urllib.request.urlopen(url)
2128
print(f"✅ Download successful")
22-
except:
29+
except Exception as err:
2330
error = True
24-
print("❌ Download failed")
31+
print(f"❌ Download failed: {err}")
2532
continue
33+
2634
filecontent = response.read()
27-
35+
2836
try:
29-
json.loads(filecontent)
37+
jstyleson.loads(filecontent)
3038
print(f"✅ JSON valid")
3139
except Exception as err:
3240
error = True

0 commit comments

Comments
 (0)