{"id":21984039,"url":"https://github.com/viralcodex/json-verifier-cli","last_synced_at":"2026-02-14T04:03:28.032Z","repository":{"id":264237633,"uuid":"892789704","full_name":"viralcodex/json-verifier-cli","owner":"viralcodex","description":"This is a custom JSON parser for validating and parsing .json files and objects through CLI or in-code.","archived":false,"fork":false,"pushed_at":"2025-02-22T18:53:40.000Z","size":4651,"stargazers_count":1,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-15T04:18:18.793Z","etag":null,"topics":["args","cli","cli-tool","js","json","json-parser","npm-package"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/viralcodex.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-22T19:30:43.000Z","updated_at":"2025-02-22T18:52:44.000Z","dependencies_parsed_at":"2025-02-22T16:27:26.484Z","dependency_job_id":"383c024b-a6ca-44f2-b517-eb887807002d","html_url":"https://github.com/viralcodex/json-verifier-cli","commit_stats":null,"previous_names":["viralcodex/json-parser","viralcodex/json-verifier-cli"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/viralcodex/json-verifier-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viralcodex%2Fjson-verifier-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viralcodex%2Fjson-verifier-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viralcodex%2Fjson-verifier-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viralcodex%2Fjson-verifier-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/viralcodex","download_url":"https://codeload.github.com/viralcodex/json-verifier-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viralcodex%2Fjson-verifier-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29435429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T03:34:37.767Z","status":"ssl_error","status_checked_at":"2026-02-14T03:34:09.092Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["args","cli","cli-tool","js","json","json-parser","npm-package"],"created_at":"2024-11-29T18:07:12.458Z","updated_at":"2026-02-14T04:03:27.999Z","avatar_url":"https://github.com/viralcodex.png","language":"JavaScript","readme":"\u003csection\u003e\u003ch2\u003eJSON Verifier (with CLI tool and Parser)\u003c/h2\u003e\u003c/section\u003e\nThis is a JSON verifier and parser created as a simple project from \u003ca href=\"https://github.com/CodingChallengesFYI\"\u003eCoding challenges\u003c/a\u003e but now being developed as a full fledged project/package.\n\n\u003cp\u003e\u003c/p\u003e\nThis tool can be used to \u003cb\u003everify\u003c/b\u003e and \u003cb\u003eparse\u003c/b\u003e JSON files. \nYou can verify and parse a \u003cb\u003esingle file\u003c/b\u003e or a \u003cb\u003efolder\u003c/b\u003e consisting of JSON files using the \u003cb\u003eCLI\u003c/b\u003e tool or use the \u003cb\u003eexported functions\u003c/b\u003e, in your own code (mentioned below).\n\n\u003csection\u003e\u003ch2\u003eHow to Use\u003c/h2\u003e\u003c/section\u003e\n\n\u003csection\u003e\u003ch3\u003eFor Running in CLI\u003c/h3\u003e\u003c/section\u003e\n\u003cli\u003eOpen your terminal and execute:\u003c/li\u003e\n\u003cp\u003e\u003c/p\u003e \n\u003cpre\u003e\u003ccode\u003enpm install -g json-verifier\u003c/code\u003e\u003c/pre\u003e\n\u003cli\u003eAfter installing, open your terminal and run \u003ccode\u003ejson-verifier\u003c/code\u003e, you will get the options on how to use the tool as below.\u003c/li\u003e\n\u003cp\u003e\u003c/p\u003e\n\n```markdown\n  Options:\n  -V, --version                   output the package version number\n  -f, --file \u003cfile_path\u003e          verify the JSON file for the file path given\n  -fd, --folder \u003cfolder_path\u003e     verify all the JSON files and parse them for the folder path given\n  -d, --max-depth \u003cnumber\u003e        set the max depth for the JSON file(s) you want to check\n  -l  --logging \u003cY/N\u003e             Choose if you want to log the results of the verification. By default it is enabled.             \n  -h, --help                      display help for available options\n```\n\n\u003csection\u003e\u003ch3\u003eFor importing as a library in code\u003c/h3\u003e\u003c/section\u003e\n\u003cli\u003eInstall the package as above, then use as mentioned below\u003c/li\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cli\u003eFor verifying and parsing a json object string\n\n```javascript\nimport { verifyJson, verifyJsonFromPath } from 'json-verifier-cli';\n\n/**\n * for verifying and parsing a json object string directly from code\n */\nconst obj = `{\"key\":\"value\", \"key2\":true}`;\nconst maxDepth : number = 10 // (optional) any integer above 0 (default is 19) \nconsole.log(verifyJson(obj, maxDepth)); //output: {key:\"value\", list:true}\n```\n\u003cli\u003eFor verifying and parsing JSON from file and folder path\n\n```javascript\n/**\n * absoluteFilePath.json\n * {\n *  \"key\":123,\n *  \"key2\": \"value\"\n *  }\n */\n\nconst filePath = './absoluteFilePath.json'\nconst maxDepth : number = 10 // (optional) any integer above 0 (default is 19) \nconst enableLoggingToFile : boolean = false // (optional) Y, y, N, n (default is Yes or enabled)\n\n/** outputs an object with filename and result (error or parsed JSON data)\n * { file: \"file1.json\", result: \u003cdata/error\u003e },\n*/\nconsole.log(verifyJsonFromPath(filePath, maxDepth, enableLoggingToFile))\n\n/**\n * absoluteFolderPath/\n *   - file1.json\n *   - file2.json\n *   - file3.json ... and so on\n */\n\nconst folderPath = './absoluteFolderPath'\n/** outputs an array of object with filename and result (error or parsed JSON data)\n * [\n * { file: \"file1.json\", result: \u003cdata/error\u003e },\n * { file: \"file2.json\", result: \u003cdata/error\u003e },\n * ]\n */\nconsole.log(verifyJsonFromPath(folderPath, maxDepth, enabledLoggingToFile)) \n```\n\u003csection\u003e\u003ch2\u003eImplementation\u003c/h2\u003e\u003c/section\u003e\nI would specially like to mention this repo by \u003ca href=\"https://github.com/eliasm307/coding-challenges/tree/main/packages/json-parser\"\u003eEliaSM\u003c/a\u003e which helped me craft an approach and write a version of mine. Please check their code out written in Typescript and try it out too!!(I'm still learning).\n\u003cp\u003e\u003c/p\u003e\nFor CLI support, I used \u003ca href=\"https://www.npmjs.com/package/commander\"\u003eCommander.js\u003c/a\u003e and \u003ca href=\"https://www.npmjs.com/package/chalk\"\u003eChalk\u003c/a\u003e.\n\u003cp\u003e\u003c/p\u003e\nI use Javascript and go through character by character for the whole data and create tokens, then stop whenever there is an invalid character or pattern in the JSON data from the file.\nThis is similar to generator function used in the above repository and this approach helps in parsing large data by not parsing it all at once but one by one and stopping whenever there is an error or invalidity is found.\n(Even though generator function is present in JS as well, I wrote a non-generator approach using OOPS to increase new)\n\n\u003csection\u003e\u003ch2\u003eTesting\u003c/h2\u003e\u003c/section\u003e\nI have used Jest for testing and test files are from \u003ca href=\"https://codingchallenges.fyi/challenges/challenge-json-parser/\"\u003eCoding Challenges\u003c/a\u003e (folders step1 to step4) and from official \u003ca href=\"https://www.json.org/\"\u003eJSON website\u003c/a\u003e (folder step5) which contains 40 \u003ca href=\"https://www.json.org/JSON_checker/test.zip\"\u003estandard tests\u003c/a\u003e for checking whether a JSON is valid or not.\n\n\u003ch5\u003eFor Already Present Test Files in the project\u003c/h5\u003e\n\u003cli\u003eClone the repo and install the dependencies by running the following command:\u003c/li\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003enpm install\u003c/code\u003e\u003c/pre\u003e\n\u003cli\u003eExecute the command to run the test files present in the repository\u003c/li\u003e\n\u003cp\u003e\u003c/p\u003e \n\u003cpre\u003e\u003ccode\u003enpm test\u003c/code\u003e\u003c/pre\u003e\n\u003cli\u003eNote: You can remove/add any test files you want and just change the \u003ccode\u003edirectories\u003c/code\u003e array in \u003ccode\u003eindex.test.js\u003c/code\u003e file if deleting/adding any new folder.\u003c/li\u003e\n\n\u003cp\u003e\u003c/p\u003e\n\n\u003csection\u003e\u003ch2\u003eContribution and Issue reporting\u003c/h2\u003e\u003c/section\u003e\n\u003cli\u003ePlease fork the repository and raise a pull request for the enhancement/bug-fix/feature/documentation. \n\u003cli\u003eFor issue reporting and feature requests, please create a new issue with proper details of the requirements/steps to reproduce and proper screenshots/videos/logs, etc to help me resolve it quickly and properly. Use proper tags to help me sort and filter all the issues and it will be easy for me as well.\n\n\u003cp\u003e\u003c/p\u003e\n\n\u003cb\u003eThanks for using my project and reading till here! Any help is much appreciated!!\u003c/b\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviralcodex%2Fjson-verifier-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviralcodex%2Fjson-verifier-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviralcodex%2Fjson-verifier-cli/lists"}