{"id":17540306,"url":"https://github.com/pabra/json-literal-typer","last_synced_at":"2025-04-23T22:29:38.710Z","repository":{"id":35136838,"uuid":"211460220","full_name":"pabra/json-literal-typer","owner":"pabra","description":"generates literal typescript iterfaces from JSON","archived":false,"fork":false,"pushed_at":"2023-08-28T19:40:35.000Z","size":357,"stargazers_count":15,"open_issues_count":11,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T04:11:37.745Z","etag":null,"topics":["json","literal","typescript"],"latest_commit_sha":null,"homepage":"https://json-literal-typer.peppnet.de/","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/pabra.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-28T07:14:01.000Z","updated_at":"2024-11-01T09:03:57.000Z","dependencies_parsed_at":"2024-06-19T19:13:40.440Z","dependency_job_id":"d1ad4f5e-bd7e-4abd-8d0e-50135ce6beec","html_url":"https://github.com/pabra/json-literal-typer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabra%2Fjson-literal-typer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabra%2Fjson-literal-typer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabra%2Fjson-literal-typer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pabra%2Fjson-literal-typer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pabra","download_url":"https://codeload.github.com/pabra/json-literal-typer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250526053,"owners_count":21445123,"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","literal","typescript"],"created_at":"2024-10-20T22:09:02.206Z","updated_at":"2025-04-23T22:29:38.693Z","avatar_url":"https://github.com/pabra.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON literal typer\n\n[![npm version](https://badge.fury.io/js/json-literal-typer.svg)](https://www.npmjs.com/package/json-literal-typer)\n[![unit-tests](https://github.com/pabra/json-literal-typer/workflows/unit-tests/badge.svg?branch=master)](https://github.com/pabra/json-literal-typer/actions?query=branch%3Amaster+workflow%3Aunit-tests)\n[![npm-publish](https://github.com/pabra/json-literal-typer/workflows/npm-publish/badge.svg)](https://github.com/pabra/json-literal-typer/actions?query=workflow%3Anpm-publish)\n[![codecov](https://codecov.io/gh/pabra/json-literal-typer/branch/master/graph/badge.svg)](https://codecov.io/gh/pabra/json-literal-typer)\n\nThere are some tools out there that will produce TypeScript Interfaces from a\ngiven JSON structure for you. But they only give you the basic types (`string`,\n`number`, etc.). What if there is an API where you want to get its literal\nvalues/types?\n\n# Install\n\n```bash\n# to add to your project\nnpm install json-literal-typer\n# to use command line interface\nnpm install --global json-literal-typer\n```\n\n# Demo\n\nThere is a live demo at [https://json-literal-typer.peppnet.de](https://json-literal-typer.peppnet.de)\n\n# Example\n\nLet's assume there is an API for gas stations. It will respond with data like\nthis:\n\n```json\n{\n  \"stations\": [\n    { \"id\": 1, \"name\": \"station A\", \"status\": \"OPEN\", \"attributes\": [\"fast\"] },\n    {\n      \"id\": 2,\n      \"name\": \"station B\",\n      \"status\": \"OPEN\",\n      \"attributes\": [\"fast\", \"24/7\"],\n      \"operator\": \"Station Corp.\"\n    },\n    {\n      \"id\": 3,\n      \"name\": \"station C\",\n      \"status\": \"CLOSED\",\n      \"attributes\": [],\n      \"operator\": \"ACME Inc.\"\n    }\n  ]\n}\n```\n\nWhat you would get from other tools is:\n\n```typescript\ninterface Station {\n  id: number;\n  name: string;\n  status: string;\n  attributes: string[];\n  operator?: string;\n}\ninterface RootObject {\n  stations: Station[];\n}\n```\n\nNice. But what if you could get:\n\n```typescript\ninterface Stations {\n  attributes: ('24/7' | 'fast')[];\n  id: 1 | 2 | 3;\n  name: 'station A' | 'station B' | 'station C';\n  operator?: 'ACME Inc.' | 'Station Corp.';\n  status: 'CLOSED' | 'OPEN';\n}\n\ninterface Root {\n  stations: Stations[];\n}\n```\n\n# CLI\n\n```bash\nnpm show json-literal-typer versions --json | json-literal-typer\n```\n\n# related or inspiring projects\n\n- [json-to-ts] - Convert jsons to typescript interfaces\n- [json2ts] - generate TypeScript interfaces from JSON\n- [quicktype] - Generate types and converters from JSON, Schema, and GraphQL\n- [ts-ast-viewer] - TypeScript AST viewer\n\n[json-to-ts]: https://github.com/MariusAlch/json-to-ts\n[json2ts]: http://www.json2ts.com/\n[quicktype]: https://github.com/quicktype/quicktype\n[ts-ast-viewer]: https://github.com/dsherret/ts-ast-viewer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabra%2Fjson-literal-typer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpabra%2Fjson-literal-typer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabra%2Fjson-literal-typer/lists"}