Skip to content

Commit 0743ccb

Browse files
committed
missing file
1 parent d5e91d7 commit 0743ccb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

json-checker.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import json
2+
import argparse
3+
4+
def check_json_syntax(file_path):
5+
try:
6+
with open(file_path, 'r') as file:
7+
json_str = file.read()
8+
json.loads(json_str)
9+
print(f"[ OK ] {file_path}")
10+
except json.JSONDecodeError as e:
11+
print(f"[FAIL] {file_path}\n\n {e}\n")
12+
except FileNotFoundError:
13+
print(f"[FAIL] {file_path}\n\n File not found\n")
14+
15+
def main():
16+
parser = argparse.ArgumentParser(description="JSON File Syntax Checker")
17+
parser.add_argument("file_path", type=str, help="Path to the JSON file for syntax checking")
18+
19+
args = parser.parse_args()
20+
check_json_syntax(args.file_path)
21+
22+
if __name__ == "__main__":
23+
main()

0 commit comments

Comments
 (0)