🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

json-typescript

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-typescript

TypeScript type definitions for JSON objects

1.1.2
latest
Source
npm
Version published
Maintainers
1
Created
Source

JSON-typescript

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

Build Status Version

How to use this

  • Install this package
npm install --save-dev json-typescript
  • Import this package
import * as _JSON from 'json-typescript';
  • 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 = [];

© 2018 Mike North, All Rights Reserved.

Keywords

jsonapi

FAQs

Package last updated on 27 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts