Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
ts-typed-json
Advanced tools
This library is a set of type definitions and utilities for dealing with JSON data in a type-safe way with TypeScript.
The most important type definitions are JSON.Value
, JSON.Object
,
and JSON.Array
, which correspond respectively to JSON values,
objects, and arrays, as the names suggest.
The library also exports safely-typed versions of the standard JSON.parse()
and JSON.stringify()
functions.
import * as JSON from 'ts-typed-json';
interface JSON.Object extends Record<string, JSON.Value> {}
interface JSON.Array extends Array<JSON.Value> {}
type JSON.Value = null | boolean | number | string | JSON.Object | JSON.Array;
Tests if a JSON value is null
.
Tests if a JSON value is a boolean.
Tests if a JSON value is a number.
Tests if a JSON value is a string.
Tests if a JSON value is a JSON object.
Tests if a JSON value is a JSON array.
Casts a JSON value to null
, throwing a TypeError
if it fails.
The optional prefix
argument allows callers to provide a contextual
string describing the value that is being tested, for the sake of
generating useful error messages in the case of a type error.
Casts a JSON value to a boolean, throwing a TypeError
if it fails.
The optional prefix
argument allows callers to provide a contextual
string describing the value that is being tested, for the sake of
generating useful error messages in the case of a type error.
Casts a JSON value to a number, throwing a TypeError
if it fails.
The optional prefix
argument allows callers to provide a contextual
string describing the value that is being tested, for the sake of
generating useful error messages in the case of a type error.
Casts a JSON value to a string, throwing a TypeError
if it fails.
The optional prefix
argument allows callers to provide a contextual
string describing the value that is being tested, for the sake of
generating useful error messages in the case of a type error.
Casts a JSON value to a JSON object, throwing a TypeError
if it fails.
The optional prefix
argument allows callers to provide a contextual
string describing the value that is being tested, for the sake of
generating useful error messages in the case of a type error.
Casts a JSON value to a JSON array, throwing a TypeError
if it fails.
The optional prefix
argument allows callers to provide a contextual
string describing the value that is being tested, for the sake of
generating useful error messages in the case of a type error.
Parses a source string as a JSON value.
Serializes a JSON value to a string.
Synchronously loads a JSON value from the filesystem.
Asynchronously loads a JSON value from the filesystem.
FAQs
JSON types and utilities for TypeScript.
We found that ts-typed-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.