json-typescript
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

JSON-typescript

TypeScript type information for compile-time validation of JSON objects.

Build Status Version

How to use this

  1. Install this package
npm install --save-dev json-typescript
  1. Import this package
import * as _JSON from 'json-typescript';
  1. Check to see if json types are validated correctly
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

© 2018 Mike North, All Rights Reserved.

Readme

Keywords

Package Sidebar

Install

npm i json-typescript

Weekly Downloads

4,445

Version

1.1.2

License

MIT

Unpacked Size

300 kB

Total Files

18

Last publish

Collaborators

  • northm