{"id":20615394,"url":"https://github.com/g-harel/ence","last_synced_at":"2025-07-15T16:08:19.712Z","repository":{"id":57225104,"uuid":"92561634","full_name":"g-harel/ence","owner":"g-harel","description":"automation friendly json schemas","archived":false,"fork":false,"pushed_at":"2018-07-26T01:20:32.000Z","size":318,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-24T06:53:05.021Z","etag":null,"topics":["automation","json","schema","structure"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g-harel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-27T01:42:20.000Z","updated_at":"2025-05-05T22:14:51.000Z","dependencies_parsed_at":"2022-08-24T11:01:09.050Z","dependency_job_id":null,"html_url":"https://github.com/g-harel/ence","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/g-harel/ence","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-harel%2Fence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-harel%2Fence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-harel%2Fence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-harel%2Fence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g-harel","download_url":"https://codeload.github.com/g-harel/ence/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-harel%2Fence/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265444740,"owners_count":23766435,"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":["automation","json","schema","structure"],"created_at":"2024-11-16T11:15:04.290Z","updated_at":"2025-07-15T16:08:19.686Z","avatar_url":"https://github.com/g-harel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ence [![NPM Version](https://img.shields.io/npm/v/ence.svg)](https://www.npmjs.com/package/ence) [![Build Status](https://travis-ci.org/g-harel/ence.svg?branch=master)](https://travis-ci.org/g-harel/ence) [![NPM Type Definitions](https://img.shields.io/npm/types/ence.svg)](https://github.com/g-harel/ence)\n\n\u003e automation friendly json schemas\n\n* Deterministic result ideal for diffs and snapshot testing\n* Full address output convenient for grep analysis\n* Missing/inconsistent object key detection\n* Compatible with any tool outputting to stdin\n\n#### Syntax\n\n```text\n.items[n].name.en :: null | string\n└────────┬──────┘    └─────┬─────┘\n      address           type(s)\n```\n\n#### Example\n\n```json\n[{\"id\": 123456, \"abc\": 31415}, {\"id\": \"654321\"}, null]\n```\n\n```text\n :: array\n[n] :: null | object\n[n].abc :: empty | number\n[n].id :: number | string\n```\n\n## Install\n\n#### CLI\n\n```shell\n$ npm install --global ence\n```\n\n#### Package\n\n```shell\n$ npm install ence\n```\n\n## Usage\n\n#### CLI\n\n```\nence [--help] [--pretty]\n```\n\n```shell\n# Explore api response data\n$ curl example.com/data.json | ence\n\n# Analyze local file\n$ cat ./data.json | ence --pretty\n```\n\n\n```shell\n# Filter top level keys\n$ ... | ence | grep -P \"^\\.\\w+ ::\"\n\n# Filter potentially empty addresses\n$ ... | ence | grep -P \"::.*empty\"\n\n# Filter mixed-type arrays\n$ ... | ence | grep -P \"\\[n\\] ::.*\\|\"\n```\n\n#### API\n\n```typescript\n// compute schema\nence(json: string, options?: Options): string\n\nconst options: Options = {\n   // customize syntax strings\n   item: \"[n]\",\n   join: \" | \",\n   key: \".\",\n   type: \" :: \",\n\n   // customize type strings\n   array: \"array\",\n   boolean: \"boolean\",\n   empty: \"empty\",\n   null: \"null\",\n   number: \"number\",\n   object: \"object\",\n   string: \"string\",\n}\n\n```\n\n```javascript\nconst ence = require(\"ence\");\n\nence(\"[]\");                  // =\u003e \" :: array\"\nence(\"[]\", {array: \"list\"}); // =\u003e \" :: list\"\n```\n\n## Performance\n\n```\nQuad core Intel Core i7-8550U @ 1.80GHz\n```\n\n```text\n+---------------------------+-----------+------------+\n| Example                   | Time (ms) | Input (kB) |\n+===========================+===========+============+\n| data-bank                 |     42.26 |    1624.44 |\n| data-reddit               |      6.74 |     207.46 |\n| data-government           |      5.44 |     168.95 |\n| array-array-object-empty  |      0.02 |       0.15 |\n| array-object-empty-simple |      0.02 |       0.13 |\n| array-object              |      0.01 |       0.10 |\n| array-object-empty-mixed  |      0.02 |       0.08 |\n| object-array-mixed        |      0.01 |       0.05 |\n| object-simple             |      0.01 |       0.05 |\n| array-simple              |      0.01 |       0.03 |\n| array-mixed               |      0.01 |       0.01 |\n| string                    |      0.00 |       0.01 |\n| boolean                   |      0.00 |       0.01 |\n| null                      |      0.00 |       0.01 |\n| number                    |      0.00 |       0.00 |\n| object                    |      0.00 |       0.00 |\n| array                     |      0.01 |       0.00 |\n+---------------------------+-----------+------------+\n```\n\nThe test cases can be found [in this directory](./examples).\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-harel%2Fence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg-harel%2Fence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-harel%2Fence/lists"}