{"id":15007572,"url":"https://github.com/isur/file-json-validator","last_synced_at":"2026-01-19T03:33:08.999Z","repository":{"id":232091064,"uuid":"783448397","full_name":"Isur/file-json-validator","owner":"Isur","description":"Tool to validate structure of json files.","archived":false,"fork":false,"pushed_at":"2024-04-18T19:35:01.000Z","size":645,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T14:46:39.063Z","etag":null,"topics":["json","nodejs","npmjs","translations"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Isur.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}},"created_at":"2024-04-07T22:39:43.000Z","updated_at":"2024-04-19T19:46:13.000Z","dependencies_parsed_at":"2024-04-18T15:55:44.078Z","dependency_job_id":null,"html_url":"https://github.com/Isur/file-json-validator","commit_stats":null,"previous_names":["isur/file-json-validator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isur%2Ffile-json-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isur%2Ffile-json-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isur%2Ffile-json-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isur%2Ffile-json-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Isur","download_url":"https://codeload.github.com/Isur/file-json-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247274378,"owners_count":20912088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["json","nodejs","npmjs","translations"],"created_at":"2024-09-24T19:11:37.170Z","updated_at":"2026-01-19T03:33:08.993Z","avatar_url":"https://github.com/Isur.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File Json Validator\n\nThis npm package is designed to simplify the comparison of directory structures and JSON files within them.\nWhether you're managing translation files with directory per language or any other scenario where maintaining consistent file structures is crucial. This tool will help you in your project.\n\n# Example use case\n\nIf you have translation files in json where each language has its own directory you can use it to check if all languages has the same file structure and all keys in json files.\n\nExample:\n\n```json\n\"scripts\": {\n  \"translations-check\": \"fjv compare ./public/locales en\",\n  \"translations-check:warn\": \"fjv compare ./public/locales en --only-warn\",\n  \"translations-check-specific\": \"fjv dir ./public/locales/en ./public/locales/pl\"\n}\n```\n\nAnd run as\n\n```bash\npnpm run translations-check\n```\n\nCan be used also in the CI - if there are any errors it will exit with error.\n\n# Features\n\n- Directory structure comparison - quickly compare if pointed directories has the same files.\n- JSON file key comparison - compare JSON's to check if their structure is the same (this compares only keys, not the values!).\n\n# Demo\n\n![demo.gif](./demo.gif)\n\n# Instalation\n\nTo install simply use your package manager to install `file-json-validator`.\n\n```bash\npnpm add file-json-validator\n```\n\n# Usage\n\n## CLI\n\n### Commands\n\n| Command       | Description                                               |\n| ------------- | --------------------------------------------------------- |\n| `fjv compare` | Compare content of directories inside selected directory. |\n| `fjv dir`     | Compare selected directories.                             |\n| `fjv json`    | Compare selected json files.                              |\n\n### Flags:\n\n| Flag                 | Description                                    | Command                  |\n| -------------------- | ---------------------------------------------- | ------------------------ |\n| `--only-warn`        | Do not exit with error if there are any diffs. | `compare`, `dir`, `json` |\n| `--show-only-errors` | Show only errors.                              | `compare`, `dir`, `json` |\n| `--only-structure`   | Check only file structure.                     | `compare`, `dir`         |\n| `--only-json`        | Check only json structure.                     | `compare`, `dir`         |\n\n## Commands description\n\n### Compare\n\nCompare content of directories inside selected directory. It will check if all directories have the same json files and if the json files has the same structures. First argument is path to the directory and the second one is the main directory that others will be compared to.\n\nIf your files are structured like this:\n\n```bash\n./public\n└── locales\n    ├── en\n    │   ├── buttons.json\n    │   └── common.json\n    ├── ger\n    │   ├── buttons.json\n    │   └── common.json\n    └── pl\n        └── common.json\n\n```\n\nThen using this:\n\n```bash\nfjv compare ./public/locales en\n```\n\nWill compare the directories `ger` and `pl` and its files with the main one `en`.\n\nIf any of the directories has different files or the files has different structure, it will show the differences and will exit with an error.\n\nIf you don't want it to exit with error you can use `--only-warn` flag.\n\nIf you don't want to see confirmation `==\u003e OK` and only see errors/warnings you can use `--show-only-errors` flag.\n\nIf you want to check only the file structure, you can use `--only-structure` flag.\n\nIf you want to check only the json structure, you can use `--only-json` flag.\n\nExample output:\n\n```bash\nDirectory structure: (1 errors)\n./public/locales/pl\n         -buttons.json\n./public/locales/ger  ==\u003e OK\nJson content: (3 errors)\n./public/locales/ger/buttons.json  ==\u003e OK\n./public/locales/pl/common.json  ==\u003e OK\n./public/locales/ger/common.json\n         -calc.minus\n         -calc.equal\n         +no\n```\n\n### Dir\n\nIf you want to compare selected directories you can use `dir` command. It will work the same as the `compare` command, but you can select directories to compare.\n\n```bash\nfjv dir ./public/locales/en ./public/locales/ger ./public/locales/pl\n```\n\nExample output:\n\n```bash\nDirectory structure: (1 errors)\n./public/locales/pl\n         -buttons.json\n./public/locales/ger  ==\u003e OK\nJson content: (3 errors)\n./public/locales/ger/buttons.json  ==\u003e OK\n./public/locales/pl/common.json  ==\u003e OK\n./public/locales/ger/common.json\n         -calc.minus\n         -calc.equal\n         +no\n```\n\n### Json\n\nIf you want to compare selected json files you can use `json` command. It will work the same as the `compare` command, but you can select json files to compare.\n\n```bash\nfjv json ./public/en/buttons.json ./public/ger/buttons.json ./public/pl/buttons.json\n```\n\nExample output:\n\n```bash\nJson: (3 errors)\n./public/pl/common.json  ==\u003e OK\n./public/ger/common.json\n         -calc.minus\n         -calc.equal\n         +no\n```\n\n## API\n\nThere are exported functions that you can import in your project:\n\n```ts\nimport {\n  compareJsonsInDirs,\n  compareDirectoriesContent,\n  compareJsonsFiles,\n  compareJsonObjects,\n} from \"file-json-validator\";\n```\n\n- `compareJsonsInDirs` - compare json files in directories.\n- `compareDirectoriesContent` - check if directories has the same files.\n- `compareJsonsFiles` - compare json files.\n- `compareJsonObjects` - compare json objects.\n\nThere are provided types for those functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisur%2Ffile-json-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisur%2Ffile-json-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisur%2Ffile-json-validator/lists"}