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

1.0.0 • Public • Published

json-types2

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

npm install -D json-types2

Usage

import { JSONValue, JSONValidObject, JSONValidArray, JSONPrimitive, JSONValidMap, JSONValidSet } from "../json-types";

Example

import { JSONValue, JSONValidObject, JSONValidArray, JSONPrimitive, JSONValidMap, JSONValidSet } from "../json-types";

interface QueryString {
	[key: string]: JSONPrimitive | undefined;
}

interface APIResponse extends JSONValidObject {
	address: {
		house_no: number;
		street: string;
	};
	name: string;
	has_website: false;
	files: JSONValidArray;
	metadata: JSONValue;
}

function httpGet(url: string): Promise<JSONValue> {
	return requestPromise(url, {
		json: true,
	});
}

Package Sidebar

Install

npm i json-types2

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

4.01 kB

Total Files

7

Last publish

Collaborators

  • movahhedi