We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d5e91d7 commit 0743ccbCopy full SHA for 0743ccb
json-checker.py
@@ -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