Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samzhangjy/ts-json-parser
A JSON parser written with TypeScript type system.
https://github.com/samzhangjy/ts-json-parser
Last synced: 9 days ago
JSON representation
A JSON parser written with TypeScript type system.
- Host: GitHub
- URL: https://github.com/samzhangjy/ts-json-parser
- Owner: samzhangjy
- License: mit
- Created: 2022-11-12T02:31:33.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-12T02:32:15.000Z (about 2 years ago)
- Last Synced: 2024-08-01T13:17:52.985Z (3 months ago)
- Language: TypeScript
- Size: 23.4 KB
- Stars: 23
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Type-level JSON Parser
A JSON parser written in TypeScript, and only TypeScript.
## Usage
First install `ts-json` with a package manager:
```bash
$ npm i ts-json-parser
```Example:
```ts
import type { JSON } from 'ts-json-parser';type Parsed = JSON<`{
"title": "My Awesome Title",
"description": "My awesome description."
}`>;/*
type Parsed = {
title: "My Awesome Title";
description: "My awesome description.";
}
*/
```To primitive types:
```ts
import type { JSONPrimitive } from 'ts-json-parser';type Parsed = JSONPrimitive<`{
"title": "My Awesome Title",
"description": "My awesome description.",
"price": 10,
"inStock": true
}`>;/*
type Parsed = {
title: string;
description: string;
price: number;
inStock: boolean;
}
*/
```## TODO
- Support floating numbers
- Support `stringify`