# json-typescript

> TypeScript type definitions for JSON objects

Latest version **1.1.2** (published 2019-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-typescript
pnpm add json-typescript
yarn add json-typescript
bun add json-typescript
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2019-03-27 |
| First published | 2017-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 292.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Mike North |
| Maintainers | northm |
| Keywords | jsonapi, typescript |

## Links

- npm: https://www.npmjs.com/package/json-typescript
- Repository: https://github.com/mike-north/json-typescript
- Homepage: https://github.com/mike-north/json-typescript#readme
- Issues: https://github.com/mike-north/json-typescript/issues
- npm.io page: https://npm.io/package/json-typescript

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.2 (latest) — 2019-03-27
- 1.1.1 — 2019-03-27
- 1.1.0 — 2018-11-07
- 1.0.1 — 2018-07-04
- 1.0.0 — 2018-01-11
- 0.0.8 — 2018-01-11
- 0.0.7 — 2018-01-11
- 0.0.6 — 2017-12-16
- 0.0.5 — 2017-12-16
- 0.0.4 — 2017-12-16
- 0.0.3 — 2017-12-16
- 0.0.2 — 2017-12-16
- 0.0.1 — 2017-12-16

## README

# JSON-typescript 

TypeScript type information for compile-time validation of [JSON objects](https://www.json.org/).

[![Build Status](https://travis-ci.org/mike-north/json-typescript.svg?branch=master)](https://travis-ci.org/mike-north/json-typescript)
[![Version](https://img.shields.io/npm/v/json-typescript.svg)](https://www.npmjs.com/package/json-typescript)

## How to use this

1. Install this package
```js
npm install --save-dev json-typescript
```

2. Import this package
```ts
import * as _JSON from 'json-typescript';
```

3. Check to see if json types are validated correctly

```ts
import * as { Value as JSONValue, Object as JSONObject } from 'json-typescript';

// ✅ This should be OK
let doc: JSONValue = {
  data: {
    type: 'articles',
    id: '1'
  }
};

// ⛔️ This should NOT be OK ( functions are not allowed )
let doc: JSONValue = {
  foo() {
    return bar;
  }
};

// ⛔️ This should NOT be OK ( Array is not a JSONObject )
let doc: JSONObject = [];
```

## Copyright
&copy; 2018 [Mike North](https://github.com/mike-north), All Rights Reserved.

---
_Source: https://npm.io/package/json-typescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
