json-types2
v1.0.0
Published
JSON TypeScript definitions
Downloads
6
Maintainers
Readme
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,
});
}