From 0743ccb0a77cc62239ec938ff3bd3bc59df8e19f Mon Sep 17 00:00:00 2001 From: "dr.lt.data" Date: Thu, 28 Dec 2023 21:37:29 +0900 Subject: [PATCH] missing file --- json-checker.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 json-checker.py diff --git a/json-checker.py b/json-checker.py new file mode 100644 index 0000000..a6c1317 --- /dev/null +++ b/json-checker.py @@ -0,0 +1,23 @@ +import json +import argparse + +def check_json_syntax(file_path): + try: + with open(file_path, 'r') as file: + json_str = file.read() + json.loads(json_str) + print(f"[ OK ] {file_path}") + except json.JSONDecodeError as e: + print(f"[FAIL] {file_path}\n\n {e}\n") + except FileNotFoundError: + print(f"[FAIL] {file_path}\n\n File not found\n") + +def main(): + parser = argparse.ArgumentParser(description="JSON File Syntax Checker") + parser.add_argument("file_path", type=str, help="Path to the JSON file for syntax checking") + + args = parser.parse_args() + check_json_syntax(args.file_path) + +if __name__ == "__main__": + main()