https://github.com/robjtede/json-types
[Deprecated] JSON TypeScript Definitions
https://github.com/robjtede/json-types
json types typescript typings
Last synced: 11 months ago
JSON representation
[Deprecated] JSON TypeScript Definitions
- Host: GitHub
- URL: https://github.com/robjtede/json-types
- Owner: robjtede
- License: mit
- Created: 2017-08-27T23:38:03.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-03-22T22:38:29.000Z (about 6 years ago)
- Last Synced: 2025-04-11T00:12:46.246Z (about 1 year ago)
- Topics: json, types, typescript, typings
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/json-types
- Size: 12.7 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Deprecation Notice
As of TypeScript 3.7, it's no longer necessary to use the workaround in this
package for defining valid JSON structures.
This small snippet is all that is required now:
```typescript
type Json =
| string
| number
| boolean
| null
| Record
| Json[];
```
---
# json-types
> JSON TypeScript Definitions
>
> A simple typescript definition module that simplifies type checking for valid JSON objects. Useful for defining interfaces and parameter type checking.
## Installation
```shell
npm i json-types
```
## Usage
```typescript
import {
Primitive,
JSONEntry,
JSONArray,
JSONMap,
JSONData
} from '../json-types'
```
### Use Case
```typescript
import {
Primitive,
JSONEntry,
JSONArray,
JSONMap,
JSONData
} from '../json-types'
interface QueryString {
[key: string]: Primitive | undefined
}
interface APIResponse extends JSONMap {
address: {
house_no: number
street: string
}
name: string,
has_website: false
files: JSONArray
metadata: JSONEntry
}
function httpGet (url: string): Promise {
return requestPromise(url, {
json: true
})
}
```