This package provides fundamental TypeScript type definitions specifically for JSON objects. Its primary purpose is to enable compile-time validation of JSON structures, ensuring that data conforms to expected shapes like `JSONValue` or `JSONObject`. The package is currently at version 1.1.2, with its last release in March 2019, indicating an inactive development cadence. Unlike more advanced libraries that generate JSON schemas from TypeScript types (e.g., `json-schema-to-typescript`) or provide runtime object mapping (e.g., `json2typescript`), `json-typescript` focuses solely on offering basic structural types for static analysis. It's suitable for projects needing straightforward type enforcement for incoming or outgoing JSON data at compile time.
npm install json-typescriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates installation and basic usage of JSON-typescript for compile-time validation of JSON structures, highlighting correct and incorrect type assignments.
For new projects or those requiring robust JSON schema validation or runtime type checking, consider actively maintained alternatives like `json-schema-to-typescript`, `typescript-json-schema` for schema generation, or `json2typescript` for runtime deserialization. If continuing to use this package, thoroughly test compatibility with your TypeScript version.
Always use `import type { Value, Object } from 'json-typescript';` for named type imports, or `import type { Value as JSONValue, Object as JSONObject } from 'json-typescript';` if aliasing. The `import * as ...` syntax is for namespace imports, not for destructuring named exports.For named type imports, use `import type { Value, Object } from 'json-typescript';` or `import type { Value as JSONValue, Object as JSONObject } from 'json-typescript';`.Ensure `tsconfig.json` has `"module": "esnext"` (or compatible), `"moduleResolution": "node"`, and `"esModuleInterop": true`. If using CommonJS, direct `require` might not provide type inference and `import` should still be preferred for type safety. Reinstall `@types/json-typescript` if it were a separate types package (not applicable here as it ships its own types).
No dependency data recorded yet.